function PhpPassword::hash

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

Overrides PasswordInterface::hash

File

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

Class

PhpPassword
Secure PHP password hashing functions.

Namespace

Drupal\Core\Password

Code

public function hash($password) {
    // Prevent DoS attacks by refusing to hash large passwords.
    if (strlen($password) > static::PASSWORD_MAX_LENGTH) {
        return FALSE;
    }
    return password_hash($password, $this->algorithm, $this->options);
}

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