This commit is contained in:
Matias Alejo Garcia 2014-10-21 09:57:54 -03:00
commit 39e85396db
7 changed files with 123 additions and 42 deletions

View file

@ -230,11 +230,22 @@ Storage.prototype.clearAll = function(cb) {
this.db.clear(cb);
};
Storage.prototype.decrypt = function(base64, password) {
// password
Storage.prototype.decrypt = function(base64, password, iterations) {
if (password) {
this.storage.savePassphrase();
var opts = iterations ? {iterations: iterations} : {};
this.storage.setPassword(password, opts);
}
var decryptedStr = this._decrypt(base64);
return JSON.parse(decryptedStr);
var ret = JSON.parse(decryptedStr);
if (password)
this.storage.restorePassphrase();
return ret;
};
Storage.prototype.encrypt = function(obj) {