-
Notifications
You must be signed in to change notification settings - Fork 810
password_hash: Update for PHP 8.4 #4455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,9 @@ | |
</listitem> | ||
<listitem> | ||
<simpara> | ||
<constant>PASSWORD_BCRYPT</constant> - Use the <constant>CRYPT_BLOWFISH</constant> algorithm to | ||
<constant>PASSWORD_BCRYPT</constant> - Use the bcrypt algorithm to | ||
create the hash. This will produce a standard <function>crypt</function> compatible hash using | ||
the "$2y$" identifier. The result will always be a 60 character string, &return.falseforfailure;. | ||
the <literal>$2y$</literal> identifier. The result will always be a 60 character string, &return.falseforfailure;. | ||
</simpara> | ||
</listitem> | ||
<listitem> | ||
|
@@ -81,8 +81,8 @@ | |
Examples of these values can be found on the <function>crypt</function> page. | ||
</para> | ||
<para> | ||
If omitted, a default value of <literal>10</literal> will be used. This is a good | ||
baseline cost, but you may want to consider increasing it depending on your hardware. | ||
If omitted, a default value of <literal>12</literal> will be used. This is a good | ||
baseline cost, but you may want to consider adjusting it depending on your hardware. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe at the same time remove personalization (i.e. usage of "you")? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's all over the document. I'll do this in a follow-up. |
||
</para> | ||
</listitem> | ||
</itemizedlist> | ||
|
@@ -153,10 +153,6 @@ | |
<para> | ||
&password.parameter.options; | ||
</para> | ||
<para> | ||
If omitted, a random salt will be created and the default cost will be | ||
used. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
</variablelist> | ||
|
@@ -187,6 +183,14 @@ | |
</row> | ||
</thead> | ||
<tbody> | ||
<row> | ||
<entry>8.4.0</entry> | ||
<entry> | ||
The default value of the <literal>cost</literal> option of the | ||
<constant>PASSWORD_BCRYPT</constant> algorithm was increased from | ||
<literal>10</literal> to <literal>12</literal>. | ||
</entry> | ||
</row> | ||
<row> | ||
<entry>8.3.0</entry> | ||
<entry> | ||
|
@@ -265,7 +269,7 @@ echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT); | |
&example.outputs.similar; | ||
<screen> | ||
<![CDATA[ | ||
$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a | ||
$2y$12$4Umg0rCJwMswRw/l.SwHvuQV01coP0eWmGzd61QH2RvAOMANUBGC. | ||
]]> | ||
</screen> | ||
</example> | ||
|
@@ -277,11 +281,10 @@ $2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a | |
<![CDATA[ | ||
<?php | ||
/** | ||
* In this case, we want to increase the default cost for BCRYPT to 12. | ||
* Note that we also switched to BCRYPT, which will always be 60 characters. | ||
* In this case, we want to increase the cost for bcrypt to 13. | ||
*/ | ||
$options = [ | ||
'cost' => 12, | ||
'cost' => 13, | ||
]; | ||
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options); | ||
?> | ||
|
@@ -290,7 +293,7 @@ echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options); | |
&example.outputs.similar; | ||
<screen> | ||
<![CDATA[ | ||
$2y$12$QjSH496pcT5CEbzjD/vtVeH03tfHKFy36d4J0Ltp3lRtee9HDxY3K | ||
$2y$13$xeDfQumlmdm0Sco.4qmH1OGfUUmOcuRmfae0dPJhjX1Bq0yYhqbNi | ||
]]> | ||
</screen> | ||
</example> | ||
|
@@ -304,13 +307,13 @@ $2y$12$QjSH496pcT5CEbzjD/vtVeH03tfHKFy36d4J0Ltp3lRtee9HDxY3K | |
/** | ||
* This code will benchmark your server to determine how high of a cost you can | ||
* afford. You want to set the highest cost that you can without slowing down | ||
* you server too much. 10 is a good baseline, and more is good if your servers | ||
* you server too much. 11 is a good baseline, and more is good if your servers | ||
* are fast enough. The code below aims for ≤ 350 milliseconds stretching time, | ||
* which is an appropriate delay for systems handling interactive logins. | ||
*/ | ||
$timeTarget = 0.350; // 350 milliseconds | ||
|
||
$cost = 10; | ||
$cost = 11; | ||
do { | ||
$cost++; | ||
$start = microtime(true); | ||
|
@@ -325,7 +328,7 @@ echo "Appropriate Cost Found: " . $cost; | |
&example.outputs.similar; | ||
<screen> | ||
<![CDATA[ | ||
Appropriate Cost Found: 12 | ||
Appropriate Cost Found: 13 | ||
]]> | ||
</screen> | ||
</example> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.