Added lib/password. Small tweaks.
This commit is contained in:
11
src/lib/password.ts
Normal file
11
src/lib/password.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
const SALT_ROUNDS = 10;
|
||||
|
||||
export function hashPassword(password: string, rounds = SALT_ROUNDS) {
|
||||
return bcrypt.hashSync(password, rounds);
|
||||
}
|
||||
|
||||
export function checkPassword(password: string, passwordHash: string) {
|
||||
return bcrypt.compareSync(password, passwordHash);
|
||||
}
|
||||
Reference in New Issue
Block a user