converting data to hex
geoff at gerrietts.net
Fri Jan 31 01:21:33 CET 2003
Quoting Mark Harrison (mh at pixar.com):
> warning: newbie alert!
> I've got an md5 digest and would like to print it as
> a hex value, but I can't get the individual hex value
> formatted. Can someone loan me a clue?
> import md5
> d = md5.new("foo")
> for x in d.digest():
> print "a", ("%02x" % x) ## how do I convert x to int???
template = '%02x' * 16
value = tuple(map(ord,md5.new(myStr).digest()))
return template % value
Geoff Gerrietts "Democracy is a form of government that substitutes
geoff at gerrietts dot net election by the incompetant many for appointment
http://www.gerrietts.net/ by the corrupt few." --George Bernard Shaw
More information about the Python-list