summaryrefslogtreecommitdiff
path: root/lib/Crypto/Random
diff options
context:
space:
mode:
authorThorsten Behrens <sbehrens@gmx.li>2011-01-05 07:54:04 -0500
committerThorsten Behrens <sbehrens@gmx.li>2011-01-05 07:54:04 -0500
commitb27696462b1e7c6c53ce2ac6760567eb6ff744b6 (patch)
tree83e2519ba30f81225c6c417f0be721926c5b04b2 /lib/Crypto/Random
parentff0e5ad4093ccbb3f1935dd7753515c42c0484e5 (diff)
downloadpycrypto-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.py4
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."""