Skip to content

Commit

Permalink
minor #40584 [PasswordHasher] The $algorithms array is only used when…
Browse files Browse the repository at this point in the history
… $algorithm is set (rosier)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[PasswordHasher] The $algorithms array is only used when $algorithm is set

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Small tweak

Commits
-------

0144d0a The $algorithms array is only used when $algorithm is set
  • Loading branch information
chalasr committed Mar 25, 2021
2 parents d91e176 + 0144d0a commit 0d08a21
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos
throw new \InvalidArgumentException('$cost must be in the range of 4-31.');
}

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

if (\defined('PASSWORD_ARGON2I')) {
$algorithms[2] = $algorithms['argon2i'] = (string) \PASSWORD_ARGON2I;
}
if (\defined('PASSWORD_ARGON2I')) {
$algorithms[2] = $algorithms['argon2i'] = (string) \PASSWORD_ARGON2I;
}

if (\defined('PASSWORD_ARGON2ID')) {
$algorithms[3] = $algorithms['argon2id'] = (string) \PASSWORD_ARGON2ID;
}
if (\defined('PASSWORD_ARGON2ID')) {
$algorithms[3] = $algorithms['argon2id'] = (string) \PASSWORD_ARGON2ID;
}

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

Expand Down

0 comments on commit 0d08a21

Please sign in to comment.