Reputation: 49384
I have a form which is storing an md5
'ed password.
For testing purposes I am using "12345" as a password.
To save the password I use: $password = md5($password);
Using the same code and the same password the PHP is creating a different md5
hash everytime although I'm using the same password each time.
Any ideas why this might be happening?
Upvotes: 0
Views: 2253
Reputation: 68476
That's not possible with md5()
, The hash will never change for a given text , It's definitely wrong with your implementation.
Maybe you are passing the md5()
hashed password as an argument to the md5()
function again and again.
There maybe some whitespace getting added to your $password
. Just trim()
it as shown below.
$password = md5(trim($password));
Remember : Even a space can change your hash.
Upvotes: 4