& so it begins

This commit is contained in:
user
2026-02-28 14:50:04 +02:00
commit f00381f2b6
536 changed files with 26294 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { argon2id, hash as argonHash, verify as argonVerify } from "argon2";
export async function hashString(target: string): Promise<string> {
const salt = Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString(
"hex",
);
const hash = await argonHash(target, {
type: argon2id,
salt: Buffer.from(salt, "hex"),
hashLength: 32,
timeCost: 3,
memoryCost: 65536,
parallelism: 1,
});
return hash;
}
export async function verifyHash({
hash,
target,
}: {
hash: string;
target: string;
}): Promise<boolean> {
try {
const isValid = await argonVerify(hash, `${target}`);
return isValid;
} catch (err) {
return false;
}
}