Using SHA1 as RNG

Klaus Alexander Seistrup spam at magnetic-ink.dk
Fri Mar 14 21:04:54 CET 2003


Giovanni Bajo wrote:

> Python 2.3 will use the Marsenne-Twister RNG, whose period is
> 2^19937-1. Big enough I'd say. It's also faster to calculate.

Thanks for bringing the good news.  Yes, 2^19937-1 is big enough
for me. :)

>> So I thought, why not use SHA1 in the core generator?
> 
> Unless you studied the distribution, you have no proof that the
> resulting sequence has a long period, for any starting seed.

Yes, you are right.  Irmen de Jong also pointed out this serious
flaw.

> And besides, it would probably be very slow.

It's not too bad, as the SHA1 modules is written in C.  However,
since I don't know anything about the distribution of numbers
within a SHA1 sequence, I'm probably better off waiting for the
Mersenne Twister to reach my Python interpreter.

Thanks for your feedback.


  // Klaus

-- 
 ><> 	unselfish actions pay back better




More information about the Python-list mailing list