16 lines
434 B
TypeScript
Executable File
16 lines
434 B
TypeScript
Executable File
import { Injectable } from "@nestjs/common";
|
|
import * as bcrypt from "bcryptjs";
|
|
|
|
@Injectable()
|
|
export class PasswordService {
|
|
private readonly saltRounds = 12;
|
|
|
|
async hashPassword(password: string): Promise<string> {
|
|
return bcrypt.hash(password, this.saltRounds);
|
|
}
|
|
|
|
async comparePasswords(plainPassword: string, hashedPassword: string): Promise<boolean> {
|
|
return bcrypt.compare(plainPassword, hashedPassword);
|
|
}
|
|
}
|