Generate a PBKDF2 key derivation of a supplied password in PHP
Description
The following code shows how to generate a PBKDF2 key derivation of a supplied password.
Example
<?php/*from www .ja va 2 s . c om*/
$password = "password";
$iterations = 1000;
// Generate a random IV using mcrypt_create_iv(),
// openssl_random_pseudo_bytes() or another suitable source of randomness
$salt = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations, 20);
echo $hash;
?>
The code above generates the following result.