开发者

Why is the same input returning two different MD5 hashes?

Alright, I have two files. They are the EXACT SAME.

The first file is: http://iadsonline.com/servconfig.php

And the second file is: http://xzerox.info/servconfig.php

However, when I use md5_file() to get their MD5, They return two different MD5's.

The first returns cc7819055cde3194bb3b136bad5cf58d, which is incorrect, and the second returns 96a0cec80eb773687ca28840ecc67ca1, which is correct.

The file is simply an &开发者_Go百科nbsp;

To verify, I've used this code:

$contents = file_get_contents($URL);
echo htmlentities($contents);

And they both return  

So why is it hashing them differently?


The second one ends in a newline, the first does not.


Trying with curl, I see the first one is   without a newline after it, the second one is   with a newline after it. So of course they'll hash differently. And indeed, even at the command line (bash prompt):

$ md5 sc.dat 
MD5 (sc.dat) = cc7819055cde3194bb3b136bad5cf58d
$ md5 zz.dat
MD5 (zz.dat) = 96a0cec80eb773687ca28840ecc67ca1


Could you have whitespace in either of those files? Open them up in a text editor and show all characters.

Alternatively, run something like this

echo str_replace(array("\n", "\t", "\r"), '[I AM HIDING!]', file_get_contents($URL));

If you see [I AM HIDING!], you will know what to do :)


this also happened with me. I set the same encoding (utf-8 without BOM) to all files that store and retrieve hashed strings :) now md5() gives the same results :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜