feat: add password hashing and JWT utils
Made-with: Cursor
This commit is contained in:
15
src/utils/password.ts
Normal file
15
src/utils/password.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as argon2 from 'argon2';
|
||||
|
||||
const HASH_OPTIONS: argon2.Options = {
|
||||
type: argon2.argon2id,
|
||||
memoryCost: 19456,
|
||||
timeCost: 2,
|
||||
};
|
||||
|
||||
export async function hashPassword(plain: string): Promise<string> {
|
||||
return argon2.hash(plain, HASH_OPTIONS);
|
||||
}
|
||||
|
||||
export async function verifyPassword(hash: string, plain: string): Promise<boolean> {
|
||||
return argon2.verify(hash, plain);
|
||||
}
|
||||
Reference in New Issue
Block a user