How to rehash a password in PHP

1 Answer

0 votes
$password = "SecurePassword123!@";
$hash = password_hash($password, PASSWORD_DEFAULT);
echo $hash . "\n";

// Rehash when algorithm changes
if (password_needs_rehash($hash, PASSWORD_DEFAULT)) {
    $hash = password_hash($password, PASSWORD_DEFAULT);
    echo $hash . "\n";
    // Save the new hash to the database
}



/*
run:

$2y$10$yLuzBib8trjVnoWddQO7DeUOS2DLeTPzrj0i9R8DnjbSgxUv6sGNm

*/

 



answered Apr 18 by avibootz
...