base con autenticacion, registro, modulo encuestas
This commit is contained in:
16
apps/api/src/common/utils/bcrypt.ts
Normal file
16
apps/api/src/common/utils/bcrypt.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { compare, hash } from 'bcryptjs';
|
||||
|
||||
const hashString = async (password: string): Promise<string> => {
|
||||
const salt = await bcrypt.genSalt(10);
|
||||
return hash(password, salt);
|
||||
};
|
||||
|
||||
const validateString = async (
|
||||
plainPassword: string,
|
||||
hashedPassword: string,
|
||||
): Promise<boolean> => {
|
||||
return await compare(plainPassword, hashedPassword);
|
||||
};
|
||||
|
||||
export { hashString, validateString };
|
||||
Reference in New Issue
Block a user