2

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

4 回答 4

5

我最好的猜测是它与“you're”一词中的 ' 标记和字符编码有关。如果您删除该报价,两个站点都会报告相同的 md5。

于 2013-08-23T21:10:14.210 回答
0

我尝试将上面的字符串逐步提供给您在问题中链接到的两个站点,事实证明,如果您正在销售 T 恤,则在 md5.cz 处破坏生成器的字符是撇号。

如果在将特殊字符的字符串提供给哈希器之前将其剥离,可能会使用 urlencode() 之类的方法保留字符串的唯一性,那么您应该获得任何字符串的匹配哈希。

于 2013-08-23T21:13:26.103 回答
0

字符串必须完全相同,包括空格。可能这些站点正在使用一些转换,例如 trim() 或 stripslashes()。仅当字符串准确时, md5 才会返回相同的值。

于 2014-08-30T03:26:38.080 回答
-1

md5 是 md5。这里的所有都是它的。如果您从不同的(非错误的)实现中获得不同的哈希值,那么您将输入不同的输入。请记住,如果输入甚至略有不同,md5 的设计目的是产生截然不同的输出。一个测试字符串末尾的单个空白字符(制表符、换行符等)将完全破坏您预期的哈希值,因为您输入了不同的输入。

于 2013-08-23T21:08:50.390 回答