summaryrefslogtreecommitdiff
path: root/pipermail/pycrypto/attachments/20110105/e35dfe76/attachment.txt
blob: 3c71ff8a7ea6051ea224f697a5731815c99e590d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/lib/Crypto/Random/random.py b/lib/Crypto/Random/random.py
index 9d969f2..c5fdb70 100644
--- a/lib/Crypto/Random/random.py
+++ b/lib/Crypto/Random/random.py
@@ -119,13 +119,11 @@ class StrongRandom(object):
             raise ValueError("sample larger than population")
 
         retval = []
-        selected = {}  # we emulate a set using a dict here
         for i in xrange(k):
-            r = None
-            while r is None or r in selected:
+            r = self.randrange(num_choices)
+            while population[r] in retval:
                 r = self.randrange(num_choices)
             retval.append(population[r])
-            selected[r] = 1
         return retval
 
 _r = StrongRandom()