feat: credential service

#8
This commit is contained in:
Mathis H (Avnyr) 2024-04-23 12:26:51 +02:00
parent a8c41b2268
commit d6cfef2a62
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -0,0 +1,16 @@
import Argon2id from "@node-rs/argon2";
export async function getHashFromPassword(password: string) {
return await Argon2id.hash(password,{
secret: Buffer.from(`${process.env["HASH_SECRET"]}`),
algorithm: 2
})
}
export async function comparePassword(password: string, hash: string) {
return await Argon2id.verify(hash, password, {
secret: Buffer.from(`${process.env["HASH_SECRET"]}`),
algorithm: 2
});
}