import { Injectable } from '@nestjs/common' ; import * as bcrypt from 'bcrypt' ; const SALT_ROUNDS = 12 ; /**
 * A cipher which uses bcrypt (https://en.wikipedia.org/wiki/Bcrypt) to hash plaintext password strings.
 */ @ Injectable ( ) export class PasswordCiper { public hash ( plaintext ) { return bcrypt . hash ( plaintext , SALT_ROUNDS ) ; } public check ( plaintext , hash ) { return bcrypt . compare ( plaintext , hash ) ; } }