diff options
Diffstat (limited to 'src/lib/password.ts')
| -rw-r--r-- | src/lib/password.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/password.ts b/src/lib/password.ts new file mode 100644 index 0000000..f5c450b --- /dev/null +++ b/src/lib/password.ts @@ -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); +} |