How to derive a secure key from a password using the PBKDF2 algorithm in PHP

1 Answer

0 votes
$password = "mySecretPassword";
$salt = random_bytes(16); // always use a random salt
$iterations = 100000;
$length = 32; // 32 bytes = 256 bits
$algo = "sha256";

$hash = hash_pbkdf2($algo, $password, $salt, $iterations, $length, true);

echo bin2hex($hash);



/*
run:

330e341cd595cf3e7146cf6baa35bfe295f77ca4969aae1cab73f50ce17ec0d1

*/

 



answered Jun 18 by avibootz

Related questions

...