Files
abode/src/util/hash.ts
T
codingetandCodex 31d4636dde
CI / install-and-build (pull_request) Successful in 1m29s
CI / format (pull_request) Successful in 51s
CI / typecheck-source (pull_request) Successful in 41s
CI / typecheck-tests (pull_request) Successful in 39s
CI / test (pull_request) Successful in 51s
CI / lint (pull_request) Successful in 21s
ci: add pull request quality gates
Co-Authored-By: gpt-5.6-terra <noreply@openai.com>
2026-07-22 21:50:29 +00:00

26 lines
577 B
TypeScript

import { argon2id, argon2Verify } from "hash-wasm";
export async function validatePassword(
password: string,
hash: string,
): Promise<boolean> {
return await argon2Verify({ password, hash });
}
export async function hashPassword(
password: string,
): Promise<`$${string}$${string}`> {
const salt = new Uint8Array(16);
crypto.getRandomValues(salt);
const hash = await argon2id({
password,
outputType: "encoded",
hashLength: 32,
iterations: 3,
memorySize: 65536,
parallelism: 4,
salt,
});
return hash as `$${string}$${string}`;
}