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

Method seed

lib/core/compat.py:29–57  ·  view source on GitHub ↗

Initialize internal state from hashable object. None or no argument seeds from current time or from an operating system specific randomness source if available. If a is not None or an int or long, hash(a) is used instead. If a is an int or long, a is used directly.

(self, a=None)

Source from the content-addressed store, hash-verified

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)."""

Callers 3

randomRangeFunction · 0.80
randomIntFunction · 0.80
randomStrFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected