move auth utils

This commit is contained in:
Milo Schwartz
2024-10-05 22:31:30 -04:00
parent 2312cdeea7
commit d9022c5377
9 changed files with 12 additions and 12 deletions

25
server/auth/password.ts Normal file
View File

@@ -0,0 +1,25 @@
import { hash, verify } from "@node-rs/argon2";
export async function verifyPassword(
password: string,
hash: string,
): Promise<boolean> {
const validPassword = await verify(hash, password, {
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1,
});
return validPassword;
}
export async function hashPassword(password: string): Promise<string> {
const passwordHash = await hash(password, {
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1,
});
return passwordHash;
}