Skip to content

Instantly share code, notes, and snippets.

@paragonie-scott
Created October 11, 2018 16:29
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save paragonie-scott/a2ea385d8d29f0903b6aed4824177464 to your computer and use it in GitHub Desktop.
Updated argon2id-bench.php
<?php
define('BENCH_ROUNDS', 200);
$start = $stop = 0.0;
$short = str_repeat("A", 16);
$long = str_repeat("A", 1 << 20);
$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 BENCH_ROUNDS, ' rounds:', PHP_EOL;
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 (1 << 20), " 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