| 1 | <?php |
||
| 5 | class Password |
||
| 6 | { |
||
| 7 | protected const SHA_512 = 'sha512'; |
||
| 8 | |||
| 9 | 1 | public function encrypt(string $password, string $salt = null, string $algorithm = self::SHA_512): PasswordData |
|
| 19 | |||
| 20 | 1 | public function verify(string $encrypted, string $password, string $salt, string $algorithm = self::SHA_512): bool |
|
| 24 | } |
||
| 25 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: