Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

disusered/cordova-safe

Repository files navigation

cordova-safe

Build Status Code Climate

Simple file encryption for Cordova.

Install

$ cordova plugin add cordova-safe

Usage

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

API

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

License

MIT © Carlos Rosquillas