PasswordService.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
12 
13 /**
14  * The PasswordService class provides services for password handling
15  *
16  * @author ingo herwig <ingo@wemove.com>
17  */
19 
20  /**
21  * Check if the given password is hashed
22  * @param $password
23  * @return boolean
24  */
25  public static function isHashed($password) {
26  $info = password_get_info($password);
27  return $info['algo'] == PASSWORD_BCRYPT;
28  }
29 
30  /**
31  * Hash the given cleartext password
32  * @param $password
33  * @return String
34  */
35  public static function hash($password) {
36  return password_hash($password, PASSWORD_BCRYPT);
37  }
38 
39  /**
40  * Check if the given hash represents the given password
41  * @param $password
42  * @param $passwordHash
43  * @return String
44  */
45  public static function verify($password, $passwordHash) {
46  return password_verify($password, $passwordHash);
47  }
48 }
static hash($password)
Hash the given cleartext password.
static isHashed($password)
Check if the given password is hashed.
The PasswordService class provides services for password handling.
static verify($password, $passwordHash)
Check if the given hash represents the given password.