md5 differences

Grant Edwards grante at visi.com
Wed Sep 10 19:37:28 CEST 2008


On 2008-09-10, Python <python at rgbaz.eu> wrote:
>
> On 10 sep 2008, at 18:30, Richard Brodie wrote:
>
>>
>> "Python" <python at rgbaz.eu> wrote in message
>> news:mailman.799.1221063937.3487.python-list at python.org...
>>
>>> here's an example:
>>> Arno at Computer:~% echo "hello" | md5
>>> b1946ac92492d2347c6235b4d2611184
>>> How do I get the same results?
>>
>> Checksum the same string.
>>
>>>>> md5.new("hello\n").hexdigest()
>> 'b1946ac92492d2347c6235b4d2611184'
>>
>>
>
> hmm and this then:
>
> Arno at Computer:~% echo "test" > test.txt
>
> Arno at Computer:~% md5 test.txt
> MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249
>
> Arno at Computer:~% python
> Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
> [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import md5
> >>> md5.new("/Volumes/data/Arno/test.txt").hexdigest()
> '90364ed45b452d43378629c20543a81d'

That's the digest of the string "/Volumes/data/Arno/test.txt".
It's not supposed to match the digest of the string "test\n".

>>> md5.new(open("test.txt").read()).hexdigest()
'd8e8fca2dc0f896fd7cb4cb0031ba249'

$ md5sum test.txt
d8e8fca2dc0f896fd7cb4cb0031ba249  test.txt

$ echo "test" | md5sum
d8e8fca2dc0f896fd7cb4cb0031ba249 -

>>> md5.new("test\n").hexdigest()
'd8e8fca2dc0f896fd7cb4cb0031ba249'

> even
> echo -n "hello" | md5
> doesn't return the same number

Not the same as _what_?

>>> md5.new("test").hexdigest()
'098f6bcd4621d373cade4e832627b4f6'

$ echo -n test | md5sum
098f6bcd4621d373cade4e832627b4f6 -


-- 
Grant Edwards                   grante             Yow! One FISHWICH coming
                                  at               up!!
                               visi.com            



More information about the Python-list mailing list