1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | namespace Nexus\Password\Hash; |
15: | |
16: | use Nexus\Password\HashInterface; |
17: | |
18: | abstract readonly class AbstractHash implements HashInterface |
19: | { |
20: | #[\Override] |
21: | public function isValidPassword(#[\SensitiveParameter] string $password): bool |
22: | { |
23: | if ('' === $password) { |
24: | return false; |
25: | } |
26: | |
27: | if (str_contains($password, "\x00")) { |
28: | return false; |
29: | } |
30: | |
31: | $passwordLength = \strlen($password); |
32: | |
33: | if ($passwordLength < self::MINIMUM_PASSWORD_LENGTH) { |
34: | return false; |
35: | } |
36: | |
37: | return $passwordLength < self::MAXIMUM_PASSWORD_LENGTH; |
38: | } |
39: | } |
40: | |