PDA

View Full Version : MD5-ing two identical values getting different results



Chris
01-05-2009, 03:33 PM
mysql's MD5 is giving me this:

md5(http://www.jdoqocy.com/click-1198878-10609240)=8327782fbf64b45a2bdc1740cebdca72
md5(http://www.jdoqocy.com/click-1198878-10609240)=8327782fbf64b45a2bdc1740cebdca

I'm at a loss. Should I do the MD5 in PHP instead of mysql?

KLB
02-03-2009, 08:51 AM
mysql's MD5 is giving me this:

md5(http://www.jdoqocy.com/click-1198878-10609240)=8327782fbf64b45a2bdc1740cebdca72
md5(http://www.jdoqocy.com/click-1198878-10609240)=8327782fbf64b45a2bdc1740cebdca

I'm at a loss. Should I do the MD5 in PHP instead of mysql?

Could it just be a truncating of the returned value in the second instance? I ran your MD5 string through MySQL and kept getting the first value.

Chris
02-04-2009, 06:50 AM
There is no truncating in either instance, anywhere in the code.

The point was to make sure I only add the link to the database once, but it was being added multiple times because of the md5 strings being slightly different. So why would MySQL take it upon itself (or php for that matter) to truncate it without me telling it to?

KLB
02-04-2009, 10:44 AM
There is no truncating in either instance, anywhere in the code.

The point was to make sure I only add the link to the database once, but it was being added multiple times because of the md5 strings being slightly different. So why would MySQL take it upon itself (or php for that matter) to truncate it without me telling it to?

What were the differences between the two instances of running the MD5 function? Was it on the same MySQL server?

The length of an MD5 hash is supposed to be 32 characters long. If it is shorter than this then something went wrong.