bcryptjs npm code example
Example 1: npm bcrypt
npm install bcrypt
Example 2: bcryptjs
npm i bcryptjs
# yarn
yarn add bcryptjs
Example 3: install bcrypt
>> npm install bcrypt
const bcrypt = require('bcrypt');
Example 4: install bcrypt
npm install bcrypt
Example 5: install bcrypt
npm install bcryptjs
Example 6: bcrypt compare hash and password
var bcrypt = dcodeIO.bcrypt;
var salt = bcrypt.genSaltSync(10);
bcrypt.hash('anypassword', salt, (err, res) => {
console.log('hash', res)
hash = res
compare(hash)
});
function compare(encrypted) {
bcrypt.compare('aboveusedpassword', encrypted, (err, res) => {
console.log('Compared result', res, hash)
})
}