Re: MD5 hash query

From: Robert Collins <>
Date: Fri, 28 Dec 2001 23:33:54 +1100

----- Original Message -----
From: "Joe Cooper" <>
> > As for the method conversion: it gets fed into the MD5 in binary, so
> > need to feed the binary value in. (ie if size(method)==4, and GET is
> > then the result will be 0x00000001 - but don't forget to adjust for
> > endianness.
> I've now fiddled with several methods of feeding binary data into the
> hashing module--but I'm not sure if any of them result in the actual
> result needed. Regardless of whether the correct data format is being
> fed, the resulting hash is still incorrect.
> I've tried both 16 bit and 32 bit binary (via a pack/unpack pair), as
> well as the Perl 5.6 sprintf %b conversion. method_t is an unsigned
> int, so I think it's 32 bits on my box--and I must assume the same
> endianness that Perl generates from an unpack operation on the same
> machine. None result in a matching MD5...

Ok, here's my 4c.

Firstly add a debug statement to the hash creation that outputs an
escaped string (ie '\\0' instead of a literal '\0'. That will give you
an exact picture of what went into a given hash.

Secondly, find some way of feeding that into perls MD5 module. Note -
and this is the most important thing - that feeding '1' in when the
binary value is '\1' is wrong. I'm no perl programmer, so pack/unpack
don't mean much to me, but if they perform _any_ conversion you will get
the wrong results.

Received on Fri Dec 28 2001 - 05:33:58 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:42 MST