mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
17 lines
420 B
TypeScript
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;
|
|
}
|
|
}
|