MD5 and SHA1 returns long hash

Hello

I am stuck with a possibly minor problem.
I have following query :


SELECT MD5( fk_groups )
FROM `groupmembers`
WHERE 1
LIMIT 0 , 30

And the out come is like:

6334636134323338613062393233383230646363353039613666373538343962

This is not the correct MD5, and my PHP script has a different MD5 i.e.

c4ca4238a0b923820dcc509a6f75849b

Please guide me why MySQL is not giving the same MD5 as PHP.

thanking you !

Best regards
ZH

I do not think this is the case.

I check the mysql website for reference, and that shows that MySQL MD5 return the results like “c4ca4238a0b923820dcc509a6f75849b”

Moreover, MD5 is already an algorithm. If they (Mysql) uses a different Algorithm, that will be called may be MD6 or something else. So when it comes to MD5 or SHA1 etc result will remain always the same. And on top of everything, based on your statement, it will be really bad bad bad, that PHP/MySQL and ASP/MSSQL all are giving 4 different MD5 for a given text. So I dont think that was the case what you wrote.

Well, I have found the solution, and this will also add to your knowledge. In fact, in my case, the MySQL is returning the HEX of MD5. So I simply used following

SELECT UNHEX(MD5( fk_groups ))
FROM groupmembers
WHERE 1
LIMIT 0 , 30

and this gave me the desired results !

Regards & Thanks for your time.

ZH

Because they don’t use the same algoritm?
Choose which one you want to use, and stick with that. I always use the PHP md5 function.