larger seeds for Mersenne

jt python at t011.com
Thu Feb 5 23:07:34 EST 2004


On Feb 5th, Tim Peters wrote:

>The .hexdigest() methods are what you're looking for.

>>>> import sha
>>>> sha.new('tim').hexdigest()
>'5ee0edb9e2229c0838f1959779f1949031de0123'
>>>> int(_, 16)
>541661208246500712261618375284272868275380945187L
>>>> md5.new('tim').hexdigest()
>'b15d47e99831ee63e3f47cf3d4478e9a'
>>>> int(_, 16)
>235757697420119658189499990054961385114L
>>>>

Thanks for the help.  I got it working and was even able to manually
verify that random.randint() wasn't accidentally hashing it anyway.

>>> import sha, random
>>> s = 'this is a test'
>>> h = hash(s)
>>> print h
-1803414999
>>> x = sha.new(s).hexdigest()
>>> y = int(x,16)
>>> print y
1428111681160539626773549155626795980060565941506
>>> z = hash(y)
>>> random.seed(h)
>>> random.randint(1,100)
53
>>> random.seed(y)
>>> random.randint(1,100)
65
>>> random.seed(z)
>>> random.randint(1,100)
27
>>>

Thanks again.

jt




More information about the Python-list mailing list