// This is probably the easiest way to use bcryptjs in nodejs
const bcrypt = require("bcryptjs")
const password = "123456"
bcrypt.hash(password, 10)
.then('''do something''')
.catch(err => console.log(err))
npm i bcryptjs
# yarn
yarn add bcryptjs
bcrypt.genSalt(saltRounds, (err, salt) => {
bcrypt.hash(yourPassword, salt, (err, hash) => {
console.log(salt + hash)
});
});
var bcrypt = require('bcryptjs');
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync("B4c0//", salt);
// Store hash in your password DB.
npm i bcryptjs
var bcrypt = require('bcryptjs');
...
// Load hash from your password DB.
bcrypt.compareSync("B4c0//", hash); // true
bcrypt.compareSync("not_bacon", hash); // false