converting data to hex

Geoff Gerrietts geoff at gerrietts.net
Fri Jan 31 14:33:41 EST 2003


Quoting Paul Rubin (phr-n2003b at NOSPAMnightsong.com):
> Mark Harrison <mh at pixar.com> writes:
> > >    value = tuple(map(ord,md5.new(myStr).digest()))
> > 
> > Most excellent...  It was only the ord that I originally
> > thought I needed, but tuple/map is so slick that now I don't
> > feel guilty about asking such a dumb question.
> 
> What are you really trying to do here?
> 
> Maybe what you want is more like
> 
>     import array
>     value = array.array('B', md5.new(myStr).digest())

I could be wrong (correct me if I am, please, Mark) but I believe what
he's looking for is an implementation of MD5.hexdigest() on a system
that doesn't have MD5.hexdigest() -- presumably a 1.5.2 system.

You can cook lots of different solutions for the problem, but the
three-liner I posted was the best combination of "clear" and "concise"
I could come up with for my application's needs.

--G.

-- 
Geoff Gerrietts           "By doing just a little every day, I can gradually 
                           let the task completely overwhelm me." 
<geoff at gerrietts net>        --Ashleigh Brilliant





More information about the Python-list mailing list