mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-23 23:52:05 -05:00
mv to argon2
This commit is contained in:
@@ -1,31 +1,12 @@
|
||||
import { verify, hash } from "@node-rs/argon2";
|
||||
|
||||
const v0x13 = 1;
|
||||
const config = {
|
||||
memorySize: 19456,
|
||||
iterations: 2,
|
||||
tagLength: 32,
|
||||
parallelism: 1,
|
||||
};
|
||||
import { verify, hash } from "argon2";
|
||||
|
||||
export function getPasswordHasher(secret: string) {
|
||||
const hashPassword = async (password: string) =>
|
||||
await hash(password.normalize("NFKC"), {
|
||||
memoryCost: config.memorySize,
|
||||
timeCost: config.iterations,
|
||||
outputLen: config.tagLength,
|
||||
parallelism: config.parallelism,
|
||||
version: v0x13,
|
||||
secret: Buffer.from(secret),
|
||||
});
|
||||
|
||||
const verifyPassword = async (password: string, hash: string) =>
|
||||
await verify(hash, password.normalize("NFKC"), {
|
||||
memoryCost: config.memorySize,
|
||||
timeCost: config.iterations,
|
||||
outputLen: config.tagLength,
|
||||
parallelism: config.parallelism,
|
||||
version: v0x13,
|
||||
secret: Buffer.from(secret),
|
||||
});
|
||||
return { hashPassword, verifyPassword };
|
||||
|
||||
Reference in New Issue
Block a user