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: #[\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: