warran / api /src /service /encrypter.ts
Jessedbrown's picture
fix: add .env to git to prevent project not running
12356f9
Raw History Blame Contribute Delete
381 Bytes
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);
}
}