Вместо 150К итераций это может быть уменьшено до 1-10К.
/* generate 44 bytes password hash
using hash key + multiple salts
*/
function hash_password($password, $key, $salts, $iteration = 1000) {
$hash = $password;
if (is_string($salts)) {
$salts = (Object)[$key => $salts];
}
foreach ($salts as $k => $salt) {
$hash = hash_pbkdf2('sha256', $hash, $k.$salt, 1000, 0, true));
}
return base64_encode(hash_pbkdf2('sha256', $hash, $key, $iteration, 0, true));
}
/* usage:
$hash = hash_password('passw@rd', 'hashkey', (Object)[ 'gen' => 'OO7', ...]);
*/