Skip to content

Commit

Permalink
examples: fix pbkdf2 invocation
Browse files Browse the repository at this point in the history
Calling `crypto.pbkdf2()` without a digest has been deprecated in Node
and is scheduled to be broken in Node 8.

Fix this by actually passing a digest.

ref: nodejs/node#11305
  • Loading branch information
addaleax committed Feb 15, 2017
1 parent abd1de7 commit 88385fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/auth/pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ var iterations = 12000;

exports.hash = function (pwd, salt, fn) {
if (3 == arguments.length) {
crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
crypto.pbkdf2(pwd, salt, iterations, len, 'sha256', function(err, hash){
fn(err, hash.toString('base64'));
});
} else {
fn = salt;
crypto.randomBytes(len, function(err, salt){
if (err) return fn(err);
salt = salt.toString('base64');
crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
crypto.pbkdf2(pwd, salt, iterations, len, 'sha256', function(err, hash){
if (err) return fn(err);
fn(null, salt, hash.toString('base64'));
});
Expand Down

0 comments on commit 88385fe

Please sign in to comment.