如何解密 php 中的散列密码?使用 password_hash() 方法散列的密码
How to decrypt the hashed password in php ? password hashed with password_hash() method
我想解密通过php的password_hash()方法加密的加密密码。
<?php
$password = 12345;
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
?>
在上面的代码中,我想将 $hashed_password
解密为 12345
。我该怎么做。
你不能。
password_hash() creates a new password hash using a strong one-way hashing algorithm.
来自 password_hash.
你不需要
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的password_hash()方法加密的加密密码。
<?php
$password = 12345;
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
?>
在上面的代码中,我想将 $hashed_password
解密为 12345
。我该怎么做。
你不能。
password_hash() creates a new password hash using a strong one-way hashing algorithm.
来自 password_hash.
你不需要
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';