brief-05-back/src/services/credential.service.ts
Mathis 56bfd8cd0d
type: style
scope: services, interfaces

subject: Apply code formatting

- Correct indentation and formatting to match code style standards in multiple 'interfaces' and 'services' files.
- Also ensure lines at the end of the files.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 10:55:37 +02:00

28 lines
567 B
TypeScript

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