File encryption for Cordova.
$ cordova plugin add org.disusered.safe
The plugin exposes the following methods:
cordova.plugins.disusered.safe.encrypt(file, key, success, error);
cordova.plugins.disusered.safe.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
var safe = cordova.plugins.disusered.safe;
// encrypt
safe.encrypt('file:/storage/sdcard/DCIM/Camera/1404177327783.jpg', 'foo');
// decrypt
safe.decrypt('file:/storage/sdcard/my-encrypted-file.txt', 'bar');
var safe = cordova.plugins.disusered.safe,
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');
}
safe.encrypt('file:/storage/sdcard/DCIM/Camera/1404177327783.jpg', key, success, error);