>> npm install bcrypt
const bcrypt = require('bcrypt');
npm install bcryptjs
npm install bcrypt
npm i bcryptjs
# yarn
yarn add bcryptjs
// Hash Password
const hashedPassword = await bcrypt.hash(req.body.password, 10)
//compare password
let password = await bcrypt.compare(req.body.password,user.password)
if(!password){
return next(CustomErrorHandler.wrongCredential())
}
var bcrypt = require('bcryptjs');
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync("B4c0//", salt);
// Store hash in your password DB.
npm i bcryptjs
bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
// Store hash in your password DB.
});
>>> import bcrypt
>>> password = b"super secret password"
>>> # Hash a password for the first time, with a randomly-generated salt
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
>>> # Check that an unhashed password matches one that has previously been
>>> # hashed
>>> if bcrypt.checkpw(password, hashed):
... print("It Matches!")
... else:
... print("It Does not Match :(")
var bcrypt = require('bcryptjs');
...
const salt = bcrypt.genSaltSync(saltRounds);
const hash = bcrypt.hashSync(myPlaintextPassword, salt);
// Store hash in your password DB.
const hash = bcrypt.hashSync(myPlaintextPassword, saltRounds);
// Store hash in your password DB.
// Load hash from your password DB.
bcrypt.compareSync("B4c0//", hash); // true
bcrypt.compareSync("not_bacon", hash); // false
>>> import bcrypt
>>> password = b"super secret password"
>>> # Hash a password for the first time, with a randomly-generated salt
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
>>> # Check that an unhashed password matches one that has previously been
>>> # hashed
>>> if bcrypt.checkpw(password, hashed):
... print("It Matches!")
... else:
... print("It Does not Match :(")