<?php
function hash_pbkdf2_reg($a = 'sha256', $password, $salt, $rounds = 5000, $key_length = 32, $raw_output = false)
{
// Derived key
$dk = '';
// Create key
for ($block=1; $block<=$key_length; $block++)
{
// Initial hash for this block
$ib = $h = hash_hmac($a, $salt . pack('N', $block), $password, true);
// Perform block iterations
for ($i=1; $i<$rounds; $i++)
{
// XOR each iteration
$ib ^= ($h = hash_hmac($a, $h, $password, true));
}
// Append iterated block
$dk .= $ib;
}
// Return derived key of correct length
$key = substr($dk, 0, $key_length);
return $raw_output ? $key : base64_encode($key);
}
$salt = '1234567890123456';
$iterations = 200000;
$length = 256;
$hash1 = hash_pbkdf2_reg('sha256', 'plnlrtfpijpuhqylxbgqiiyipieyxvfsavzgxbbcfusqkozwpngsyejqlmjsytrmd', $salt, $iterations, $length);
preferences:
47.31 ms | 402 KiB | 5 Q