mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-14 04:35:56 +02:00
18 lines
418 B
TypeScript
18 lines
418 B
TypeScript
let bcrypt: any;
|
|
try {
|
|
bcrypt = require('bcrypt');
|
|
} catch (err) {
|
|
bcrypt = require('bcryptjs');
|
|
}
|
|
|
|
export class PasswordHelper {
|
|
public static cryptPassword(password: string) {
|
|
const salt = bcrypt.genSaltSync(9);
|
|
return bcrypt.hashSync(password, salt);
|
|
}
|
|
|
|
public static comparePassword(password: string, encryptedPassword: string) {
|
|
return bcrypt.compareSync(password, encryptedPassword);
|
|
}
|
|
}
|