Skip to content

gadikotamohan/cordova-safe

 
 

Repository files navigation

safe

Build Status Code Climate

File encryption for Cordova.

Install

$ cordova plugin add org.disusered.safe

Usage

The plugin exposes the following methods:

cordova.plugins.disusered.safe.encrypt(file, key, success, error);
cordova.plugins.disusered.safe.decrypt(file, key, success, error);

Parameters:

  • file: A string representing a local URI
  • key: A key for the crypto operations
  • success: Optional success callback
  • error: Optional error callback

Example

Default usage

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');

With optional callbacks

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);

Dependencies

About

File encryption for Cordova.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 86.6%
  • Java 9.2%
  • JavaScript 3.3%
  • Shell 0.9%