File size: 381 Bytes
430550f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import * as bcrypt from 'bcryptjs';
export class Encrypter {
public async hash(text: string): Promise<string> {
const rounds = 12;
const salt = await bcrypt.genSalt(rounds);
const result = await bcrypt.hash(text, salt);
return result;
}
public async compare(text: string, hash: string): Promise<boolean> {
return await bcrypt.compare(text, hash);
}
}
|