mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 16:51:15 +10:00
23 lines
583 B
TypeScript
23 lines
583 B
TypeScript
import bcrypt from "bcryptjs";
|
|
import * as argon2 from "argon2";
|
|
import { type } from "arktype";
|
|
|
|
export const simpleAuth = type({
|
|
version: "string.semver",
|
|
password: "string",
|
|
});
|
|
|
|
export type SimpleAuthType = typeof simpleAuth.infer;
|
|
|
|
export async function checkHashBcrypt(password: string, hash: string) {
|
|
return await bcrypt.compare(password, hash);
|
|
}
|
|
|
|
export async function createHashArgon2(password: string) {
|
|
return await argon2.hash(password);
|
|
}
|
|
|
|
export async function checkHashArgon2(password: string, hash: string) {
|
|
return await argon2.verify(hash, password);
|
|
}
|