A PhoneGap plugin to encrypt strings using RNCryptor/JNCryptor (iOS/Android)
The plugin exposes two methods:
var rncryptor = cordova.require("com.disusered.simplecrypto.SimpleCrypto");
rncryptor.encrypt(key, data, successCallback, failureCallback)
rncryptor.decrypt(key, data, successCallback, failureCallback)
The parameters:
Useless cyclical example.
var rncryptor = cordova.require("com.disusered.simplecrypto.SimpleCrypto");
var key = 'myKey';
function failureCallback(error) {
console.log('Error: ' + error);
}
function successCallback(encryptedData) {
console.log('Encrypted data: ' + encryptedData);
rncryptor.decrypt(key, encryptedData,
function successCallback(decryptedData) {
console.log('Decrypted data: ' + decryptedData);
}, failureCallback);
}
rncryptor.encrypt(key, 'My data to encode', successCallback, failureCallback);
Useless cyclical example.
var rncryptor = cordova.require("com.disusered.simplecrypto.SimpleCrypto");
var key = 'myKey';
function failureCallback(error) {
console.log('Error: ' + error);
}
function successCallback(encryptedData) {
console.log('Encrypted data: ' + encryptedData);
rncryptor.decrypt(key, encryptedData,
function successCallback(decryptedData) {
console.log('Decrypted data: ' + decryptedData);
}, failureCallback);
}
rncryptor.encrypt(key, 'My data to encode')
.then(successCallback)
.catch(failureCallback);
This plugin uses the Objective-C implementation of RNCryptor. RNCryptor is a CCCryptor (AES encryption) wrapper for iOS and Mac. The data format includes all the metadata required to securely implement AES encryption. It is returned as a base64 string using NSData+Base64. The encrypted blob includes:
This plugin uses the Java implementation of RNCryptor, JNCryptor. JNCryptor is an easy-to-use library for encrypting data with AES. It was ported to Java from the RNCryptor library for iOS.