MySQL's MD5 hash is incorrect

会有一股神秘感。 提交于 2019-12-23 01:45:11

问题


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!


回答1:


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




回答2:


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)



来源:https://stackoverflow.com/questions/3783347/mysqls-md5-hash-is-incorrect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!