Last active
October 11, 2018 16:29
-
-
Save paragonie-scott/265074ed288f8944ff014dbf2cd83210 to your computer and use it in GitHub Desktop.
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 | |
define('BENCH_ROUNDS', 100); | |
$start = $stop = 0.0; | |
$short = str_repeat("A", 16); | |
$long = str_repeat("A", 65535); | |
$start = microtime(true); | |
for ($i = 0; $i < BENCH_ROUNDS; ++$i) { | |
sodium_crypto_pwhash_str($short, SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE); | |
} | |
$end = microtime(true); | |
echo "16 char password: ", number_format($end - $start, 3), " seconds.", PHP_EOL; | |
$start = microtime(true); | |
for ($i = 0; $i < BENCH_ROUNDS; ++$i) { | |
sodium_crypto_pwhash_str($long, SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE); | |
} | |
$end = microtime(true); | |
echo "65536 char password: ", number_format($end - $start, 3), " seconds.", PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://gist.github.com/paragonie-scott/a2ea385d8d29f0903b6aed4824177464 for an updated version