const SALT = '盐值';
export const hashPassword = (password) => {
if (!password) return '';
const hash = crypto.createHash('sha256');
hash.update(password + SALT);
return hash.digest('hex');
};
export const verifyPassword = (inputPassword, hashedPassword) => {
if (!inputPassword || !hashedPassword) return false;
const hashedInput = hashPassword(inputPassword);
return hashedInput === hashedPassword;
};
最后修改:2026 年 05 月 15 日
© 允许规范转载
1 条评论
看不懂