- var_dump: documentation ( source)
- password_hash: documentation ( source)
- hash_hmac: documentation ( source)
- password_verify: documentation ( source)
- base64_encode: documentation ( source)
<?php
$randomPassword = base64_encode(hash_hmac('sha256', 'example password', openssl_random_pseudo_bytes(32)));
$hash = password_hash($randomPassword, PASSWORD_DEFAULT, ['cost' => 12]);
var_dump([
$randomPassword,
$hash
]);
if (password_verify($randomPassword, $hash)) {
var_dump(['status' => 'success']);
} else {
echo 'I can\'t let you do that, Dave!', "\n";
exit(1);
}