- password_hash: documentation ( source)
- hash: documentation ( source)
- base64_encode: documentation ( source)
<?php
/* nul byte (\u0000) safe password hashing function based on password_hash (uses "bcrypt" algorithm).
* Source : https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016 by CiPHPCoder
* Code: @Florent_ATo
*/
function safePasswordHash($password) {
return password_hash(
base64_encode(
hash('sha384', $password, false)
), PASSWORD_BCRYPT, array('cost' => 12)
);
}
$password = '*********password-longer-than-72-characters-and-with-\0-sequence*********';
print safePasswordHash($password);
?>