-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordHelper.php
More file actions
44 lines (38 loc) · 958 Bytes
/
PasswordHelper.php
File metadata and controls
44 lines (38 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Helper;
/**
* Simplified PasswordHelper based on this example.
*
* @see: https://www.phpjabbers.com/generate-a-random-password-with-php-php70.html
*/
class PasswordHelper
{
/**
* Get password hash of the given password.
*
* @param $password
*
* @return string
*/
public static function getPasswordHash($password)
{
$passwordHash = '';
if (!empty($password)) {
$passwordHash = password_hash($password, PASSWORD_DEFAULT, ['cost' => 10]);
}
return $passwordHash;
}
/**
* Match the given password with the hashed password.
*
* @param string $loginPassword
* @param string $userHashPassword
*
* @return bool
*/
public static function verifyPassword($loginPassword, $userHashPassword)
{
$isVerified = password_verify($loginPassword, $userHashPassword);
return $isVerified;
}
}