<?php
$password = "password";
$iterations = 600000;
// Genera un salt criptográficamente seguro aleatorio usando la función random_bytes(),
$salt = random_bytes(16);
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations, 20);
var_dump($hash);
// Para binario bruto, $length debe ser dividido por dos para resultados equivalentes
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations, 10, true);
var_dump(bin2hex($hash));
?>
Resultado del ejemplo anterior es similar a:
string(20) "120fb6cffcf8b32c43e7"
string(20) "120fb6cffcf8b32c43e7"