Skip to content

Commit 5d5e91c

Browse files
committed
The $algorithms array is only used when $algorithm is set
1 parent 9faf432 commit 5d5e91c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Hasher/NativePasswordHasher.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos
4949
throw new \InvalidArgumentException('$cost must be in the range of 4-31.');
5050
}
5151

52-
$algorithms = [1 => \PASSWORD_BCRYPT, '2y' => \PASSWORD_BCRYPT];
52+
if (null !== $algorithm) {
53+
$algorithms = [1 => \PASSWORD_BCRYPT, '2y' => \PASSWORD_BCRYPT];
5354

54-
if (\defined('PASSWORD_ARGON2I')) {
55-
$algorithms[2] = $algorithms['argon2i'] = (string) \PASSWORD_ARGON2I;
56-
}
55+
if (\defined('PASSWORD_ARGON2I')) {
56+
$algorithms[2] = $algorithms['argon2i'] = (string) \PASSWORD_ARGON2I;
57+
}
5758

58-
if (\defined('PASSWORD_ARGON2ID')) {
59-
$algorithms[3] = $algorithms['argon2id'] = (string) \PASSWORD_ARGON2ID;
60-
}
59+
if (\defined('PASSWORD_ARGON2ID')) {
60+
$algorithms[3] = $algorithms['argon2id'] = (string) \PASSWORD_ARGON2ID;
61+
}
6162

62-
if (null !== $algorithm) {
6363
$this->algorithm = $algorithms[$algorithm] ?? $algorithm;
6464
}
6565

0 commit comments

Comments
 (0)