我想解密通过php的password_hash()方法加密后的加密密码
<?php
$password = 12345;
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
?>
在上面的代码中,我想将 $hashed_password
解密为 12345
。我该怎么做。
最佳答案
你不需要
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';
关于php - 如何在 php 中解密散列密码?使用 password_hash() 方法散列的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52273284/