début hashage
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
9bfd03b19a
commit
04f9fd9c04
@ -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