1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/model/PasswordHelper.ts

13 lines
336 B
TypeScript
Raw Normal View History

2017-07-13 00:31:19 +08:00
import * as bcryptjs from "bcryptjs";
2017-07-10 04:36:25 +08:00
export class PasswordHelper {
2017-07-11 15:01:59 +08:00
public static cryptPassword(password) {
2017-07-13 00:31:19 +08:00
const salt = bcryptjs.genSaltSync(10);
return bcryptjs.hashSync(password, salt);
2017-07-10 04:36:25 +08:00
}
2017-07-11 15:01:59 +08:00
public static comparePassword(password, encryptedPassword) {
2017-07-13 00:31:19 +08:00
return bcryptjs.compareSync(password, encryptedPassword);
2017-07-10 04:36:25 +08:00
}
}