Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash function broken in Node v0.10 #3

Merged
merged 1 commit into from Nov 22, 2013
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
@@ -55,7 +55,9 @@ exports.hash = function(pwd, salt, fn){
if (3 == arguments.length) {
if (!pwd) return fn(new Error('password missing'));
if (!salt) return fn(new Error('salt missing'));
crypto.pbkdf2(pwd, salt, iterations, len, fn);
crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
fn(err, (new Buffer(hash, 'binary')).toString('base64'));
});
} else {
fn = salt;
if (!pwd) return fn(new Error('password missing'));
@@ -64,7 +66,7 @@ exports.hash = function(pwd, salt, fn){
salt = salt.toString('base64');
crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
if (err) return fn(err);
fn(null, salt, hash);
fn(null, salt, (new Buffer(hash, 'binary')).toString('base64'));
});
});
}