Created
September 17, 2015 08:59
-
-
Save potfur/08932a22eb028df3a98f to your computer and use it in GitHub Desktop.
bcrypt cost calculator
This file contains 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 | |
$mooreLawConst = 18; | |
$defaults = 6; // from initial implementation for normal user | |
$monthsFromPublication = (new \DateTime('1999-12-31'))->diff(new \DateTime()); | |
$monthsFromPublication = $monthsFromPublication->y * 12 + $monthsFromPublication->m + round($monthsFromPublication->d / 31); | |
$cost = $defaults + $monthsFromPublication / $mooreLawConst; | |
var_dump($cost); | |
$start = microtime(true); | |
password_hash('somepasswordstring', \CRYPT_BLOWFISH, ['cost' => $cost]); | |
var_dump(microtime(true) - $start); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment