Skip to content

Commit

Permalink
Use the new PHP 5.5 password api with polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy Baukema committed Feb 4, 2013
1 parent d69fda5 commit bf7024a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Security/Encoder/BlowfishPasswordEncoder.php
Expand Up @@ -41,12 +41,11 @@ public function __construct($cost)

public function encodePassword($raw, $salt = null)
{
$salt = substr(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36), 0, 22);
return crypt($raw, '$2a$' . $this->cost . '$'. $salt . '$');
return password_hash($raw, PASSWORD_BCRYPT, array('cost' => $this->cost));
}

public function isPasswordValid($encoded, $raw, $salt = null)
{
return $this->comparePasswords($encoded, crypt($raw, $encoded));
return password_verify($raw, $encoded);
}
}
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -14,7 +14,8 @@
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": ">=2.0,<2.3",
"symfony/security-bundle": ">=2.0,<2.3"
"symfony/security-bundle": ">=2.0,<2.3",
"ircmaxell/password-compat": "1.0.*"
},
"autoload": {
"psr-0": { "Elnur\\BlowfishPasswordEncoderBundle": "" }
Expand Down

0 comments on commit bf7024a

Please sign in to comment.