Skip to content

Commit

Permalink
Passwords: BCRYPT changed to default algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 11, 2018
1 parent 8647df3 commit bc0f81d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Security/Passwords.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function hash(string $password, array $options = []): string
throw new Nette\InvalidArgumentException("Cost must be in range 4-31, $options[cost] given.");
}

$hash = password_hash($password, PASSWORD_BCRYPT, $options);
$hash = password_hash($password, PASSWORD_DEFAULT, $options);
if ($hash === false || strlen($hash) < 60) {
throw new Nette\InvalidStateException('Hash computed by password_hash is invalid.');
}
Expand All @@ -50,6 +50,6 @@ public static function verify(string $password, string $hash): bool
*/
public static function needsRehash(string $hash, array $options = []): bool
{
return password_needs_rehash($hash, PASSWORD_BCRYPT, $options);
return password_needs_rehash($hash, PASSWORD_DEFAULT, $options);
}
}

3 comments on commit bc0f81d

@JanTvrdik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad idea because there is no guarantee that PASSWORD_DEFAULT will work with the options you're providing, e.g. PASSWORD_ARGON2I requires different options.

@JanTvrdik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically as far as I understand it, PASSWORD_DEFAULT will work well only if you remove support for passing custom $options.

@dg
Copy link
Member Author

@dg dg commented on bc0f81d Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have plan to change it to an object.

I'll get this out.

Please sign in to comment.