How to decrypt the hashed password in php ? passwo

2020-04-18 07:22发布

I want to decrypt the encrypted password that is encrypted by php's password_hash() method.

<?php

    $password = 12345;
    $hashed_password = password_hash($password, PASSWORD_DEFAULT);

?>

in above code i want to decrypt $hashed_password to 12345. how can i do it.

2条回答
家丑人穷心不美
2楼-- · 2020-04-18 07:41

You don't need to

The used algorithm, cost and salt are returned as part of the hash. Therefore, all information that's needed to verify the hash is included in it. This allows the password_verify() function to verify the hash without needing separate storage for the salt or algorithm information.

    $passwordEnteredFirstTime = '12345';
    $passwordEnteredSecondTime = '12345';

    $passwordHash = password_hash($passwordEnteredFirstTime, PASSWORD_BCRYPT);
    $passIsValid = password_verify($passwordEnteredSecondTime, $passwordHash);
    echo $passIsValid ? 'correct password' : 'wrong password';
查看更多
你好瞎i
3楼-- · 2020-04-18 07:51

You can't.

password_hash() creates a new password hash using a strong one-way hashing algorithm.

From password_hash.

查看更多
登录 后发表回答