MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / WichmannHill

Class WichmannHill

lib/core/compat.py:22–169  ·  view source on GitHub ↗

Reference: https://svn.python.org/projects/python/trunk/Lib/random.py

Source from the content-addressed store, hash-verified

20import uuid
21
22class WichmannHill(random.Random):
23 """
24 Reference: https://svn.python.org/projects/python/trunk/Lib/random.py
25 """
26
27 VERSION = 1 # used by getstate/setstate
28
29 def seed(self, a=None):
30 """Initialize internal state from hashable object.
31
32 None or no argument seeds from current time or from an operating
33 system specific randomness source if available.
34
35 If a is not None or an int or long, hash(a) is used instead.
36
37 If a is an int or long, a is used directly. Distinct values between
38 0 and 27814431486575L inclusive are guaranteed to yield distinct
39 internal states (this guarantee is specific to the default
40 Wichmann-Hill generator).
41 """
42
43 if a is None:
44 try:
45 a = int(binascii.hexlify(os.urandom(16)), 16)
46 except NotImplementedError:
47 a = int(time.time() * 256) # use fractional seconds
48
49 if not isinstance(a, int):
50 a = hash(a)
51
52 a, x = divmod(a, 30268)
53 a, y = divmod(a, 30306)
54 a, z = divmod(a, 30322)
55 self._seed = int(x) + 1, int(y) + 1, int(z) + 1
56
57 self.gauss_next = None
58
59 def random(self):
60 """Get the next random number in the range [0.0, 1.0)."""
61
62 # Wichman-Hill random number generator.
63 #
64 # Wichmann, B. A. & Hill, I. D. (1982)
65 # Algorithm AS 183:
66 # An efficient and portable pseudo-random number generator
67 # Applied Statistics 31 (1982) 188-190
68 #
69 # see also:
70 # Correction to Algorithm AS 183
71 # Applied Statistics 33 (1984) 123
72 #
73 # McLeod, A. I. (1985)
74 # A remark on Algorithm AS 183
75 # Applied Statistics 34 (1985),198-200
76
77 # This part is thread-unsafe:
78 # BEGIN CRITICAL SECTION
79 x, y, z = self._seed

Callers 1

resetMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…