const bcrypt = require('bcrypt');

function CompareNewPasswords(newPass, confirmPass) {
    if (newPass === confirmPass) {
        return true;
    }

    return false;
}

function CheckPasswodLength(newPass) {
    if (newPass.length < 8) {
        return false;
    }

    return true;
}

async function HashPassword(newPass) {
    const saltRounds = 12;
    const someOtherPlaintextPassword = 'not_bacon';

    return await bcrypt.hash(newPass, saltRounds);
}

async function ComparePassword(pass, hash) {
    return await bcrypt.compare(pass, hash);
}

module.exports = {
    CompareNewPasswords,
    CheckPasswodLength,
    HashPassword,
    ComparePassword,
}