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

18 lines
389 B
TypeScript

let bcrypt;
try {
bcrypt = require("bcrypt");
} catch (err) {
bcrypt = require("bcryptjs");
}
export class PasswordHelper {
public static cryptPassword(password) {
const salt = bcrypt.genSaltSync(9);
return bcrypt.hashSync(password, salt);
}
public static comparePassword(password, encryptedPassword) {
return bcrypt.compareSync(password, encryptedPassword);
}
}