1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 23:03:32 +00:00

hashpassword with callback

This commit is contained in:
Kyle Spearrin
2016-09-05 00:03:49 -04:00
parent 8f0a24b1b9
commit cc67d12c57
2 changed files with 27 additions and 23 deletions

View File

@@ -67,17 +67,19 @@ function initCryptoService() {
return key;
};
CryptoService.prototype.hashPassword = function (password, key) {
if (!key) {
key = this.getKey();
}
CryptoService.prototype.hashPassword = function (password, key, callback) {
this.getKey(false, function (storedKey) {
if (!key) {
key = storedKey;
}
if (!password || !key) {
throw 'Invalid parameters.';
}
if (!password || !key) {
throw 'Invalid parameters.';
}
var hashBits = sjcl.misc.pbkdf2(key, password, 1, 256, null);
return sjcl.codec.base64.fromBits(hashBits);
var hashBits = sjcl.misc.pbkdf2(key, password, 1, 256, null);
callback(sjcl.codec.base64.fromBits(hashBits));
});
};
CryptoService.prototype.getAes = function (callback) {