Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Password / PasswordInterface.php
1 <?php
2
3 namespace Drupal\Core\Password;
4
5 /**
6  * Secure password hashing functions for user authentication.
7  */
8 interface PasswordInterface {
9
10   /**
11    * Maximum password length.
12    */
13   const PASSWORD_MAX_LENGTH = 512;
14
15   /**
16    * Hash a password using a secure hash.
17    *
18    * @param string $password
19    *   A plain-text password.
20    *
21    * @return string
22    *   A string containing the hashed password, or FALSE on failure.
23    */
24   public function hash($password);
25
26   /**
27    * Check whether a plain text password matches a hashed password.
28    *
29    * @param string $password
30    *   A plain-text password
31    * @param string $hash
32    *   A hashed password.
33    *
34    * @return bool
35    *   TRUE if the password is valid, FALSE if not.
36    */
37   public function check($password, $hash);
38
39   /**
40    * Check whether a hashed password needs to be replaced with a new hash.
41    *
42    * This is typically called during the login process when the plain text
43    * password is available. A new hash is needed when the desired iteration
44    * count has changed by a modification of the password-service in the
45    * dependency injection container or if the user's password hash was
46    * generated in an update like user_update_7000() (see the Drupal 7
47    * documentation).
48    *
49    * @param string $hash
50    *   The existing hash to be checked.
51    *
52    * @return bool
53    *   TRUE if the hash is outdated and needs rehash.
54    */
55   public function needsRehash($hash);
56
57 }