Taher
Taher

Reputation: 12040

MySQL's MD5 hash is incorrect

PHP's md5("123123") gives me a correct value of 4297f44b13955235245b2497399d7a93, while mysql's

select md5("123123");

gives me '6e9abeea535938c496a261b3b39c0d79'.

Why would this happen ? does this have anything to do with mysql server incoding? I kinda lost it, help much appreciated!

Thank you!

Upvotes: 1

Views: 4112

Answers (2)

Young
Young

Reputation: 8356

6e9abeea535938c496a261b3b39c0d79 is the value of md5("132123"),so I think you have a type mistake.

Upvotes: 17

Dagg Nabbit
Dagg Nabbit

Reputation: 76736

I get the same value from mysql and php. Might have something to do with multi-byte characters?


mysql> select md5("123123");
+----------------------------------+
| md5("123123")                    |
+----------------------------------+
| 4297f44b13955235245b2497399d7a93 |
+----------------------------------+
1 row in set (0.00 sec)
  • mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1

php > echo md5("123123");
4297f44b13955235245b2497399d7a93
  • PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:41:55)

Upvotes: 1

Related Questions