1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus framework.
7: *
8: * (c) John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
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: