Converting strings to hex
dale at out-think.NOSPAMco.uk
Fri May 19 02:11:05 CEST 2000
The output from MD5.digest() is a 16 byte binary string.
I want to convert it to hex for printing.
The hex() function only handles integers (pah!) so I've come up with this:
string.join(map(wibble, list(a)), "")
Which is ugly, at best.
Is there a better way?
I've just discovered unpack and come up with this:
"%4X %4X %4X %4X" % struct.unpack(">4i", a)
which is certainly shorter!
Is this the best I can expect?
Out-Think Ltd, UK
More information about the Python-list