Skip to content

Instantly share code, notes, and snippets.

Created August 25, 2014 13:30
What would you like to do?
Benchmark Pbkdf2 iterations with ZF2
// Benchmark the Pbkdf2 iteration (10'000 = 50 ms, using an Intel i5 CPU at 2)
use Zend\Crypt\Key\Derivation\Pbkdf2;
use Zend\Math\Rand;
$salt = Rand::getBytes(32);
$pass = 'this is the password of the user';
$start = microtime(true);
$hash = Pbkdf2::calc('sha256', $pass, $salt, 10000, 32);
$end = microtime(true);
printf ("Hash : %s\n", base64_encode($hash));
printf ("Exec. time: %.2f\n", $end-$start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment