Skip to content

Commit 88385fe

Browse files
committed
examples: fix pbkdf2 invocation
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
1 parent abd1de7 commit 88385fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/auth/pass.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ var iterations = 12000;
3131

3232
exports.hash = function (pwd, salt, fn) {
3333
if (3 == arguments.length) {
34-
crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
34+
crypto.pbkdf2(pwd, salt, iterations, len, 'sha256', function(err, hash){
3535
fn(err, hash.toString('base64'));
3636
});
3737
} else {
3838
fn = salt;
3939
crypto.randomBytes(len, function(err, salt){
4040
if (err) return fn(err);
4141
salt = salt.toString('base64');
42-
crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
42+
crypto.pbkdf2(pwd, salt, iterations, len, 'sha256', function(err, hash){
4343
if (err) return fn(err);
4444
fn(null, salt, hash.toString('base64'));
4545
});

0 commit comments

Comments
 (0)