1/*
2 you can skip doing bcrypt.genSalt and use
3 bcrypt.hash(password, 10, function(err, hash) {..});
4 this is working fine for me:
5*/
6
7var bcrypt = require('bcrypt');
8
9bcrypt.hash('mypassword', 10, function(err, hash) {
10 if (err) { throw (err); }
11
12 bcrypt.compare('mypassword', hash, function(err, result) {
13 if (err) { throw (err); }
14 console.log(result);
15 });
16});
1import bcrypt from 'bcryptjs'
2
3export const matchPassword = async (enteredpassword, oldPassword) => {
4 return await bcrypt.compare(enteredpassword, oldPassword)
5}