Commit 358473c1 authored by Guido van Rossum's avatar Guido van Rossum

Andrew Kuchling writes:

First, the RNG in whrandom.py sucks if you let it seed itself from the time.
The problem is the line:
			t = int((t&0xffffff) | (t>>24))
Since it ORs the two parts together, the resulting value has mostly
ON bits.  Change | to ^, and you don't lose any randomness.
parent 1aedbd8b
......@@ -50,7 +50,7 @@ class whrandom:
# Initialize from current time
import time
t = long(time.time() * 256)
t = int((t&0xffffff) | (t>>24))
t = int((t&0xffffff) ^ (t>>24))
t, x = divmod(t, 256)
t, y = divmod(t, 256)
t, z = divmod(t, 256)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment