You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
287 B
11 lines
287 B
// 密码加密与校验工具
|
|
import bcrypt from "bcryptjs"
|
|
|
|
export async function hashPassword(password) {
|
|
const salt = await bcrypt.genSalt(10)
|
|
return bcrypt.hash(password, salt)
|
|
}
|
|
|
|
export async function comparePassword(password, hash) {
|
|
return bcrypt.compare(password, hash)
|
|
}
|
|
|