converting data to hex
Geoff Gerrietts
geoff at gerrietts.net
Thu Jan 30 19:35:39 EST 2003
Quoting Paul Rubin (phr-n2003b at NOSPAMnightsong.com):
> Mark Harrison <mh at pixar.com> writes:
> > 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???
>
> If you want hex, just say
>
> d = md5.new("foo")
> print d.hexdigest()
Paul's right, as long as you're not stuck on 1.5.2 (or wanting to be
compatible with it).
--
Geoff Gerrietts <geoff at gerrietts dot net>
I AM YOUR KING! BOW BEFORE ME, PEASANT! -- Dogbert
More information about the Python-list
mailing list