MD5 to long?

Alex Martelli aleax at aleax.it
Sat Apr 26 12:31:28 CEST 2003


Axel Grune wrote:

> Hi, is there any function which can convert a MD5 or SHA1 sum
> (e.g. fd4cef7a4e607f1fcc920ad6329a6df2df99a4e8) to a long integer?

Just call the built-in type long, with a second argument of 16, and
you can easily turn any sequence of hex digits into a long.  E.g.:

>>> import md5
>>> mm = md5.new('four score and seven years ago')
>>> print mm.hexdigest()
6b1c88b5b09b86d22fb12b50f74a19a3
>>> long(mm.hexdigest(), 16)
142375552663685867188287505851356944803L
>>>


Alex





More information about the Python-list mailing list