Reputation: 55
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.
Upvotes: 2
Views: 13865
Reputation: 639
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';
Upvotes: 5
Reputation: 14365
You can't.
password_hash() creates a new password hash using a strong one-way hashing algorithm.
From password_hash.
Upvotes: 3