File tree 1 file changed +11
-1
lines changed
src/Symfony/Component/Security/Core/Encoder
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -53,14 +53,24 @@ public function __construct($cost)
53
53
* the "$2y$" salt prefix (which is not available in the early PHP versions).
54
54
* @see https://github.com/ircmaxell/password_compat/issues/10#issuecomment-11203833
55
55
*
56
+ * It is almost best to **not** pass a salt and let PHP generate one for you.
57
+ *
56
58
* @param string $raw The password to encode
57
59
* @param string $salt The salt
58
60
*
59
61
* @return string The encoded password
62
+ *
63
+ * @link http://lxr.php.net/xref/PHP_5_5/ext/standard/password.c#111
60
64
*/
61
65
public function encodePassword ($ raw , $ salt )
62
66
{
63
- return password_hash ($ raw , PASSWORD_BCRYPT , array ('cost ' => $ this ->cost ));
67
+ $ options = array ('cost ' => $ this ->cost );
68
+
69
+ if ($ salt ) {
70
+ $ options ['salt ' ] = $ salt ;
71
+ }
72
+
73
+ return password_hash ($ raw , PASSWORD_BCRYPT , $ options );
64
74
}
65
75
66
76
/**
You can’t perform that action at this time.
0 commit comments