Skip to content

Instantly share code, notes, and snippets.

@ezimuel
Created August 25, 2014 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezimuel/0769f99e45a04e124cf0 to your computer and use it in GitHub Desktop.
Save ezimuel/0769f99e45a04e124cf0 to your computer and use it in GitHub Desktop.
Benchmark Pbkdf2 iterations with ZF2
<?php
// 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