1
0
mirror of https://github.com/moparisthebest/mail synced 2024-08-13 16:43:47 -04:00
mail/src/js/crypto/pbkdf2.js

21 lines
594 B
JavaScript
Raw Normal View History

2013-04-02 09:02:57 -04:00
/**
2013-05-14 06:01:51 -04:00
* A Wrapper for Forge's PBKDF2 function
2013-04-02 09:02:57 -04:00
*/
app.crypto.PBKDF2 = function() {
'use strict';
2013-03-13 11:58:46 -04:00
/**
2013-04-02 09:02:57 -04:00
* PBKDF2-HMAC-SHA1 key derivation with a constant salt and 1000 iterations
* @param password [String] The password in UTF8
* @param keySize [Number] The key size in bits
* @return [String] The base64 encoded key
2013-03-13 11:58:46 -04:00
*/
2013-04-02 09:02:57 -04:00
this.getKey = function(password, keySize) {
2013-05-14 06:01:51 -04:00
var salt = forge.util.decode64("vbhmLjC+Ub6MSbhS6/CkOwxB25wvwRkSLP2DzDtYb+4=");
var key = forge.pkcs5.pbkdf2(password, salt, 1000, keySize / 8);
var keyBase64 = forge.util.encode64(key);
2013-04-02 09:02:57 -04:00
return keyBase64;
2013-03-13 11:58:46 -04:00
};
2013-04-02 09:02:57 -04:00
};