[Pythonmac-SIG] x-platform md5 (endian?)

Just van Rossum just@letterror.com
Wed, 3 Nov 1999 11:42:39 +0100


At 10:56 AM +0100 11/3/99, Jack Jansen wrote:
>> I did a little experiment with the MD5 module: I created an md5 digest for a
>> file on a Windows machine and then created an md5 digest for the same file
>> on a Mac and it turned out the digests do not match. Might this be because
>> of the "endian-ism" of the two platforms?
>
>I've done cross-platform MD5s, and they worked. But it could be that I tried
>it on a big-endian unix box and a big-endian mac. Still, I'd expect MD5 to be
>byte-based.
>
>Maybe you should ask this in a general Python forum (and report back here)?

Quick test: it works. Bob, maybe it's the text/binary issue once more?

[just@rietveld just]$ python
Python 1.5.1 (#1, Mar 21 1999, 22:49:36)  [GCC egcs-2.91.66 19990314/Li on
linux
-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import md5
>>> d = md5.new()
>>> d.update("abcdefghijkl")
>>> d.digest()
'\237\311\326\006\221 0\334\250e\202\355bY\\\367'
>>> import struct
>>> struct.pack("h", 1)
'\001\000'
>>>



Python 1.5.2+ (#43, Mar  9 1999, 13:06:43)  [CW PPC w/GUSI w/MSL]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import md5
>>> d = md5.new()
>>> d.update("abcdefghijkl")
>>> d.digest()
'\237\311\326\006\221 0\334\250e\202\355bY\\\367'
>>>
>>> import struct
>>> struct.pack("h", 1)
'\000\001'
>>>