parent
2ced946d16
commit
689d1c8944
@ -0,0 +1,18 @@
|
|||||||
|
import * as bcrypt from "bcryptjs";
|
||||||
|
|
||||||
|
const saltRounds = 10; // Le nombre de tours de salage
|
||||||
|
|
||||||
|
/* Fonction pour hasher le mot de passe */
|
||||||
|
export async function hashPassword(password: string): Promise<string> {
|
||||||
|
const hashedPassword = await bcrypt.hash(password, saltRounds);
|
||||||
|
return hashedPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fonction pour vérifier le mot de passe */
|
||||||
|
export async function comparePassword(
|
||||||
|
plainPassword: string,
|
||||||
|
hashedPassword: string
|
||||||
|
): Promise<boolean> {
|
||||||
|
const isMatch = await bcrypt.compare(plainPassword, hashedPassword);
|
||||||
|
return isMatch;
|
||||||
|
}
|
Loading…
Reference in new issue