Skip to content

Commit

Permalink
Use 2a algo ident until node bcrypt has 2y support
Browse files Browse the repository at this point in the history
- 2y algo is identical to 2a except for fixing an issue with unicode input
  strings so this should be safe to do.
- A request to add support for the 2y identifier has been opened here:
  kelektiv/node.bcrypt.js#175 , once this is
  implemented go back to using the origin repo.
  • Loading branch information
MitchellMcKenna committed Jul 15, 2013
1 parent 5d44eec commit df0a987
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function password_hash($password, $algo, array $options = array()) {
$raw_salt_len = 16;
// The length required in the final serialization
$required_salt_len = 22;
$hash_format = sprintf("$2y$%02d$", $cost);
$hash_format = sprintf("$2a$%02d$", $cost);
break;
default:
trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
Expand Down Expand Up @@ -155,10 +155,10 @@ function password_get_info($hash) {
'algoName' => 'unknown',
'options' => array(),
);
if (substr($hash, 0, 4) == '$2y$' && strlen($hash) == 60) {
if (substr($hash, 0, 4) == '$2a$' && strlen($hash) == 60) {
$return['algo'] = PASSWORD_BCRYPT;
$return['algoName'] = 'bcrypt';
list($cost) = sscanf($hash, "$2y$%d$");
list($cost) = sscanf($hash, "$2a$%d$");
$return['options']['cost'] = $cost;
}
return $return;
Expand Down

0 comments on commit df0a987

Please sign in to comment.