Cordova File Encryption Plugin for Android and iOS.
$ cordova plugin add cordova-plugin-file-encryption
var encryptor = cordova.plugins.fileEncryption,
key = 'someKey';
function success(encryptedFile) {
console.log('Encrypted file: ' + encryptedFile);
safe.decrypt(encryptedFile, key, function(decryptedFile) {
console.log('Decrypted file: ' + decryptedFile);
}, error);
}
function error() {
console.log('Error with cryptographic operation');
}
encryptor.encrypt('file:/storage/sdcard/DCIM/Camera/1404177327783.jpg', key, success, error);
The plugin exposes the following methods:
cordova.plugins.fileEncryption.encrypt(file, key, success, error);
cordova.plugins.fileEncryption.decrypt(file, key, success, error);
- file: A string representing a local URI
- key: A key for the crypto operations
- success: Optional success callback
- error: Optional error callback