Example #1
0
function passwords_validate_password($password, $enc_password)
{
    if ($GLOBALS['cfg']['passwords_use_bcrypt']) {
        $h = new BCryptHasher();
        return $h->CheckPassword($password, $enc_password);
    }
    $test = passwords_encrypt_password($password);
    return $test == $enc_password;
}
Example #2
0
function passwords_validate_password($password, $enc_password, $more = array())
{
    $defaults = array('use_bcrypt' => 1);
    $more = array_merge($defaults, $more);
    if ($GLOBALS['passwords_canhas_bcrypt'] && $more['use_bcrypt']) {
        $h = new BCryptHasher();
        return $h->CheckPassword($password, $enc_password);
    }
    $test = passwords_encrypt_password($password, $more);
    $len_test = strlen($test);
    $len_pswd = strlen($enc_password);
    if ($len_test != $len_pswd) {
        return 0;
    }
    for ($i = 0; $i < $len_test; $i++) {
        if ($test[$i] != $enc_password[$i]) {
            return 0;
        }
    }
    return 1;
}
Example #3
0
function users_update_password(&$user, $new_password)
{
    $enc_password = passwords_encrypt_password($new_password);
    return users_update_user($user, array('password' => AddSlashes($enc_password)));
}