dsq2015 2013-08-23 13:06
浏览 179
已采纳

例如,不同意相同字符串的md5哈希值

This is getting me crazy, my md5's don't agree. I have this string:

The Combinations Generator is a tool that allows you to easily create a series of combinations by selecting the related attributes. For example, if you're selling t-shirts in three different sizes and two different colors, the generator will create six combinations for you.

When I hash it on my computer using the md5 function (with php 5.5.0) it produces the following hash: 422f3f656e1a5f95e8b5cf7565d815b5

http://www.miraclesalad.com/webtools/md5.php agrees with my computer's result.

http://www.md5.cz/ disagrees with both my computer and miraclesalad.

This string/md5 pair was initially computed by another computer which also gives the same result as md5.cz.

I read about encoding issues (although the string doesn't contain any non ASCII characters), so I tried the following code on my computer:

<?php

$str = "The Combinations Generator is a tool that allows you to easily create a series of combinations by selecting the related attributes. For example, if you're selling t-shirts in three different sizes and two different colors, the generator will create six combinations for you.";

echo "$str<BR/>";
echo md5($str)."<BR/>";
echo md5(utf8_encode($str))."<BR/>";
echo md5(utf8_decode($str))."<BR/>";


die();

The output is:

The Combinations Generator is a tool that allows you to easily create a series of combinations by selecting the related attributes. For example, if you're selling t-shirts in three different sizes and two different colors, the generator will create six combinations for you.

422f3f656e1a5f95e8b5cf7565d815b5

422f3f656e1a5f95e8b5cf7565d815b5

422f3f656e1a5f95e8b5cf7565d815b5

So it is not about utf8.

Any idea what's happening?

展开全部

  • 写回答

4条回答 默认 最新

  • drqvsx1228 2013-08-23 13:10
    关注

    My best guess is that it has something to do with the ' mark in the word "you're" and character encodings. If you remove that quote both sites report the same md5.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部