How does Python generate random numbers?
I understand that I should be using os.urandom()
or SystemRandom
in Python for "safe" pseudo-random numbers.
But how does Python generate these random numbers logically?
Also is there a way to generate a number in Python that is "more random" than others?
For "safe" random numbers, Python does not actually generate them: it gets them from the operating system, which has a special driver that collects entropy from various sources in the real world, such as changes in time between keystrokes and disk tends.
I answered a very similar question, because it is very detailed (it covers both Random
and SystemRandom
).
ANSWER LINK