Converting strings to hex
dale at out-think.NOSPAMco.uk
Thu May 18 20:11:05 EDT 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