On Thu, 28 Sep 2006 10:57:19 -0700, David Bear <>
declaimed the following in comp.lang.python:
> Yes, this is what I am doing. Because I am using code sold to me by a vendor
> -- I was worried that they are doing something with it that had some
> dependencies on the way perl was making the digest. So I was trying to
> better understand the perl by doing it in python.
For the most part, it looks like they were trying to preset the
result to some sort of padding, then modifying parts of that to contain
the real data.
Since Python strings are immutable, one way to produce a right
padded string is just to concatenate the data with padding, then
slice...
res = "".join([data, "pad"*lngth])[:lngth]
The XOR needs to be done piecewise...; presuming both sides (a and
b) are same length (which I presume the padding is meant to achieve)
res = "".join([chr(ord(a[i]) ^ ord(b[i]) for i in len(a)])
--
Wulfraed Dennis Lee Bieber KD6MOG
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff:
web-)
HTTP://www.bestiaria.com/