API/api.medcify.app/helper/hashing.js
2022-09-26 11:41:44 +05:30

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;