I have a piece of code below where it echos a salted password:
$pass = rand();
$pass = md5($pass);
$pass = substr($pass, 0, 15);
$pass = md5(md5("g3f".$pass."rt4"));
Now if I echo $pass, then it will output this for example:
8723d9c8a8b2af798be25fd07ab0ff0a
But what I want to do is echo the password itself so that for example instead of displaying the above it will display the string which is "password".
How can this be achieved?
Thanks
You can't. Hashing is a one way street. If you want to hide a string that needs to be shown later, you'd need to use encryption instead. However, this is a taboo when it comes to passwords.
To address the second part of the question, you should NEVER send user passwords via email. Implement a server-side solution (for instance use security questions + verification of their email) and after authentication allow users to change their passwords directly on the website.
Oh, and one more thing - forget about MD5!!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With