import { Encoder } from '@/use-cases/ports' ; import * as bcrypt from 'bcrypt' ; export class BcryptEncoder implements Encoder { private readonly rounds : number = 10 ; constructor ( rounds ) { this . rounds = rounds ; } async encode ( plain ) { return await bcrypt . hash ( plain , this . rounds ) ; } async compare ( plain , hashed ) { return await bcrypt . compare ( plain , hashed ) ; } }