Files
pcpuma_unam_api/src/bcrypt/bcrypt.service.ts
T

21 lines
526 B
TypeScript
Raw Normal View History

2022-04-21 17:49:08 -05:00
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import * as bcrypt from 'bcrypt';
@Injectable()
export class BcryptService {
constructor(private configService: ConfigService) {}
encriptar(password: string) {
const salt = bcrypt.genSaltSync(
2022-05-02 14:40:17 -05:00
parseInt(this.configService.get<string>('SALT_ROUNDS')),
2022-04-21 17:49:08 -05:00
);
return bcrypt.hashSync(password, salt);
}
comparar(password: string, passwordDb: string) {
return bcrypt.compareSync(password, passwordDb);
}
}