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?

有帮助吗?

解决方案

That's not possible with md5() , The hash will never change for a given text , It's definitely wrong with your implementation.

The two cases of failure

  • 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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top