Converting strings to hex
jay graves
jgraves3 at austin.rr.com
Thu May 18 21:47:56 EDT 2000
On Fri, 19 May 2000 00:28:46 GMT, kzaragoza at mediaone.net (Kris J.
Zaragoza) wrote:
>That's funny, I was _just_ playing with this very functionality!
>def md5ToHex(md5string):
> import string
> ret = []
> for c in md5string:
> ret.append("%02X" % ord(c))
> return string.join(ret,"")
>
It must be something in the air. I also needed this yesterday and a
DejaNews search yielded this function from Michael Wallace.
def hexify(binaryString):
result = ""
for i in binaryString:
result = result + string.zfill(hex(ord(i))[2:],2)
return result
Jay
More information about the Python-list
mailing list