I\'m currently learning about encryption and password safety in NodeJS. I\'m working with a current example that currently is using PBKDF2, I\'d like to switch this out to use S
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);
};