bcrypt 加密
bcrypt 加密
引入
npm i bcrypt -S
代码
加密
const bcrypt = require("bcrypt")
const salt = bcrypt.genSaltSync(10);
const hash = bcrypt.hashSync(password, salt);//加密
验证
const isMatch = bcrypt.compareSync(password, hash);//验证
npm i bcrypt -S
加密
const bcrypt = require("bcrypt")
const salt = bcrypt.genSaltSync(10);
const hash = bcrypt.hashSync(password, salt);//加密
验证
const isMatch = bcrypt.compareSync(password, hash);//验证