Created
May 28, 2014 07:36
-
-
Save calvinchengx/24cf8c48fcd2f0182704 to your computer and use it in GitHub Desktop.
Example module export for nodejs libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sjcl = require('sjcl'); | |
var RNCryptor = {}; | |
/* | |
Takes password string and salt WordArray | |
Returns key bitArray | |
*/ | |
module.exports.KeyForPassword = RNCryptor.KeyForPassword = function(password, salt) { | |
var hmacSHA1 = function (key) { | |
var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha1); | |
this.encrypt = function () { | |
return hasher.encrypt.apply(hasher, arguments); | |
}; | |
}; | |
return sjcl.misc.pbkdf2(password, salt, 10000, 32 * 8, hmacSHA1); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment