On Thu, May 22, 2014 at 11:54 PM, Adam Funk <a24...@ducksburg.com> wrote:
>> >>> from hashlib import sha1
>> >>> s = "Hello world"
>> >>> h = sha1(s)
>> >>> h.hexdigest()
>> >>> int(h.hexdigest(), 16)
> That ties in with a related question I've been wondering about lately
> (using MD5s & SHAs for other things) --- getting a hash value (which
> is internally numeric, rather than string, right?) out as a hex string
> & then converting that to an int looks inefficient to me --- is there
> any better way to get an int? (I haven't seen any other way in the
I don't know that there is, at least not with hashlib. You might be
able to use digest() followed by the struct module, but it's no less
convoluted. It's the same in several other languages' hashing
functions; the result is a string, not an integer.