e-scooter-rental-system/server/utils/password.js

18 lines
329 B
JavaScript

const bcrypt = require('bcryptjs');
/**
* 密码哈希
*/
const hashPassword = async (password) => {
return await bcrypt.hash(password, 10);
};
/**
* 密码比对
*/
const comparePassword = async (password, hash) => {
return await bcrypt.compare(password, hash);
};
module.exports = { hashPassword, comparePassword };