I am using this line to generate a sha1 id for node.js:
crypto.createHash(\'sha1\').digest(\'hex\');
The problem is that it\'s returning th
Using crypto
is a good approach cause it's native and stable module,
but there are cases where you can use bcrypt
if you want to create a really strong and secure hash. I use it for passwords it has a lot of techniques for hashing, creating salt and comparing passwords.
Technique 1 (generate a salt and hash on separate function calls)
const salt = bcrypt.genSaltSync(saltRounds);
const hash = bcrypt.hashSync(myPlaintextPassword, salt);
Technique 2 (auto-gen a salt and hash):
const hash = bcrypt.hashSync(myPlaintextPassword, saltRounds);
For more examples you can check here: https://www.npmjs.com/package/bcrypt