Created
April 11, 2014 18:51
-
-
Save Garbee/10491841 to your computer and use it in GitHub Desktop.
Test PHP password_hash timing
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
<?php | |
$timeTarget = 0.2; | |
$cost = 9; | |
do { | |
$cost++; | |
$start = microtime(true); | |
password_hash("test", PASSWORD_BCRYPT, ["cost" => $cost]); | |
$end = microtime(true); | |
} while (($end - $start) < $timeTarget); | |
echo "Appropriate Cost Found: " . $cost . "\n"; |
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
Run this by setting the target time you want for a password to be hashed. Then run it to find out what a good cost level is for your hardware. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment