Here's an example:
'use strict';
function sha256(buf) {
return crypto.createHash('sha256').update(buf).digest('hex');
}
var crypto = require('crypto');
var secret = 'my special secret';
var appPbkdf2Salt = sha256(new Buffer("MY_SALT"));
var iterations = 1000;
var bitLength; // oops, forgot to define bit length
var keyByteLength = bitLength / 8;
var hashname = 'sha256';
crypto.pbkdf2(secret, appPbkdf2Salt, iterations, keyByteLength, hashname, function (err, bytes) {
if (err) {
throw err;
}
console.log('bytes', bytes.toString('hex'));
});
I'm assuming that NaN is coerced to 0. I would think that 0 should also throw an error.