If wanted to generate sha256
hashes, then you'd have to drop the iterations and length property as those are specific to pbkdf2
. You would then use crypto.createHash()
which uses OpenSSL to generate hashes. That being said, the types of hashes you can generate are dependent on the version of OpenSSL that you have installed.
var crypto = require('crypto');
var hash = crypto.createHash('sha256').update(pwd).digest('base64');
Your specific implementation might look like this:
var crypto = require('crypto');
module.exports = function(pwd, fn) {
var hash = crypto.createHash('sha256').update(pwd).digest('base64');
fn(null, hash);
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…