<?php
$password = "password";
$iterations = 600000;
// Generate a cryptographically secure random salt using random_bytes()
$salt = random_bytes(16);
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations, 20);
var_dump($hash);
// for raw binary, the $length needs to be halved for equivalent results
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations, 10, true);
var_dump(bin2hex($hash));?>
Il precedente esempio visualizzerà
qualcosa simile a:
string(20) "120fb6cffcf8b32c43e7"
string(20) "120fb6cffcf8b32c43e7"