23 lines
587 B
JavaScript
23 lines
587 B
JavaScript
const bcrypt=require('bcryptjs');
|
|
|
|
const saltRound = 10;
|
|
|
|
//Encryption create a hashpassword ee
|
|
const hashGenerate=async(plainPassword)=>
|
|
{
|
|
const salt=await bcrypt.genSalt(saltRound);
|
|
const hash=await bcrypt.hash(plainPassword,salt);
|
|
return hash;
|
|
}
|
|
|
|
//Compare Plain pwd and hashpassword
|
|
//const existingUser=await models.Employee.findOne({where:{email:req.body.password}});
|
|
const hashValidator=async(plainPassword,oldpwd)=>
|
|
{
|
|
const result=await bcrypt.compare(plainPassword,oldpwd);
|
|
return result;
|
|
}
|
|
|
|
module.exports.hashGenerate=hashGenerate;
|
|
module.exports.hashValidator=hashValidator;
|