B-crypt init

PHOTO EMBED

Thu Aug 19 2021 18:50:18 GMT+0000 (Coordinated Universal Time)

Saved by @ExplodeMilk #express #b-crypt

import * as bcrypt from 'bcryptjs';

const SALT_ROUNDS = 10;

export async function hashPassword(plainPassword:string) {
    const hash = await bcrypt.hash(plainPassword,SALT_ROUNDS);
    return hash;
};


export async function checkPassword(plainPassword:string,hashPassword:string){
    const match = await bcrypt.compare(plainPassword,hashPassword);
    return match;
}
content_copyCOPY

npm install bcryptjs @types/bcryptjs