diff options
author | Thorsten Behrens <sbehrens@gmx.li> | 2011-01-05 07:54:04 -0500 |
---|---|---|
committer | Thorsten Behrens <sbehrens@gmx.li> | 2011-01-05 07:54:04 -0500 |
commit | b27696462b1e7c6c53ce2ac6760567eb6ff744b6 (patch) | |
tree | 83e2519ba30f81225c6c417f0be721926c5b04b2 /lib/Crypto/Random | |
parent | ff0e5ad4093ccbb3f1935dd7753515c42c0484e5 (diff) | |
download | pycrypto-b27696462b1e7c6c53ce2ac6760567eb6ff744b6.tar.gz |
Improve random selftest
o Random selftest is improved, less likely to collide
o random.shuffle() is more pythonic
Diffstat (limited to 'lib/Crypto/Random')
-rw-r--r-- | lib/Crypto/Random/random.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/Crypto/Random/random.py b/lib/Crypto/Random/random.py index bc08889..9d969f2 100644 --- a/lib/Crypto/Random/random.py +++ b/lib/Crypto/Random/random.py @@ -109,9 +109,7 @@ class StrongRandom(object): # Choose a random item (without replacement) until all the items have been # chosen. for i in xrange(len(x)): - p = self.randint(1,len(items)) - x[i] = items[p-1] - del items[p-1] + x[i] = items.pop(self.randrange(len(items))) def sample(self, population, k): """Return a k-length list of unique elements chosen from the population sequence.""" |