13 lines
293 B
JavaScript
13 lines
293 B
JavaScript
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);
|
|
}
|