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

17 lines
420 B
TypeScript

import * as bcrypt from 'bcrypt';
export class PasswordHelper {
public static cryptPassword(password: string): string {
const salt = bcrypt.genSaltSync(9);
return bcrypt.hashSync(password, salt);
}
public static comparePassword(password: string, encryptedPassword: string): boolean {
try {
return bcrypt.compareSync(password, encryptedPassword);
} catch (e) {
}
return false;
}
}