function PhpPassword::check

Same name in other branches
  1. 10 core/lib/Drupal/Core/Password/PhpPassword.php \Drupal\Core\Password\PhpPassword::check()

Overrides PasswordInterface::check

File

core/lib/Drupal/Core/Password/PhpPassword.php, line 43

Class

PhpPassword
Secure PHP password hashing functions.

Namespace

Drupal\Core\Password

Code

public function check($password, $hash) {
    // Prevent DoS attacks by refusing to check large passwords.
    if (strlen($password) > static::PASSWORD_MAX_LENGTH) {
        return FALSE;
    }
    // Newly created accounts may have empty passwords.
    if ($hash === NULL || $hash === '') {
        return FALSE;
    }
    return password_verify($password, $hash);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.