converting data to hex

Geoff Gerrietts geoff at
Fri Jan 31 01:21:33 CET 2003

Quoting Mark Harrison (mh at
> 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 ="foo")
> for x in d.digest():
>     print "a", ("%02x" % x)  ## how do I convert x to int???

def make_digest(myStr):

    template = '%02x' * 16

    value = tuple(map(ord,

    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   by the corrupt few." --George Bernard Shaw

More information about the Python-list mailing list