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: | public function isValidPassword(#[\SensitiveParameter] string $password): bool |
21: | { |
22: | if ('' === $password) { |
23: | return false; |
24: | } |
25: | |
26: | if (str_contains($password, "\x00")) { |
27: | return false; |
28: | } |
29: | |
30: | $passwordLength = \strlen($password); |
31: | |
32: | if ($passwordLength < self::MINIMUM_PASSWORD_LENGTH) { |
33: | return false; |
34: | } |
35: | |
36: | return $passwordLength < self::MAXIMUM_PASSWORD_LENGTH; |
37: | } |
38: | } |
39: | |