MD5 to long?

Alex Martelli aleax at
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 ='four score and seven years ago')
>>> print mm.hexdigest()
>>> long(mm.hexdigest(), 16)


More information about the Python-list mailing list