Inital Commit
This commit is contained in:
12
server/password.js
Normal file
12
server/password.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
const ROUNDS = 10;
|
||||
|
||||
export async function hashPassword(plain) {
|
||||
return bcrypt.hash(plain, ROUNDS);
|
||||
}
|
||||
|
||||
export async function verifyPassword(plain, hash) {
|
||||
if (!hash || typeof hash !== 'string') return false;
|
||||
return bcrypt.compare(plain, hash);
|
||||
}
|
||||
Reference in New Issue
Block a user