Merge pull request #1930 from cmgustavo/feature/pin-01

PIN for mobile devices
This commit is contained in:
Matias Alejo Garcia 2014-12-03 23:56:10 -03:00
commit 6f1342ea27
21 changed files with 589 additions and 130 deletions

View file

@ -59,22 +59,22 @@ module.exports = {
/**
* Encrypts symmetrically using a passphrase
*/
encrypt: function(key, message) {
encrypt: function(key, message, salt, iter) {
if (!_.isString(message)) {
message = JSON.stringify(message);
}
sjcl.json.defaults.salt = defaultSalt;
sjcl.json.defaults.iter = defaultIterations;
sjcl.json.defaults.salt = salt || defaultSalt;
sjcl.json.defaults.iter = iter || defaultIterations;
return sjcl.encrypt(key, message);
},
/**
* Decrypts symmetrically using a passphrase
*/
decrypt: function(key, cyphertext) {
decrypt: function(key, sjclEncryptedJson) {
var output = {};
try {
return sjcl.decrypt(key, cyphertext);
return sjcl.decrypt(key, sjclEncryptedJson);
} catch (e) {
log.info('Decryption failed due to error: ' + e.message);
return null;