Files
Guardian/passwordcheck.js
T
2023-10-10 17:07:22 +02:00

20 lines
542 B
JavaScript

const bcrypt = require('bcrypt');
class PassCheck{
constructor(BcryptSaltRounds, PassPolicyOptions) {
this.BcryptSaltRounds = BcryptSaltRounds;
this.PassPolicy = new PassPolicy(PassPolicyOptions);
}
async verifyPassword(password, hash) {
return await bcrypt.compare(password, hash);
}
async hashPassword(password) {
const salt = await bcrypt.genSalt(this.BcryptSaltRounds);
const hash = await bcrypt.hash(password, salt);
return hash;
}
}
module.exports = PassCheck;