Forum Thread: How Random Works in Python

Is it possible to know which number would random generate.
Or How does random work?
Is it possible to make my own random function ?

1 Response

AFAIK, the random function in languages are psuedo-random, which means they only seem to be random but are not entirely since they have a set mathematical equation to produce the result. Because of this, using the default random generator functions can cause issues in situations where security is required because mathematics is predictable, you will always get the same answer for every given scenario.

In cases where you would want to create true (or near-true) randomness, usually sources (yes, sometimes more than one) with high entropy are gathered and combined for greater effectiveness. Where might you find these sources? Normally, they are generated from physical phenomena such as the speed of the CPU fan or the air turbulence from disk drives*. Mouse movement and keyboard presses may also be sourced but don't usually produce as good an outcome.

*Wikipedia article on Entropy (Computing)

Share Your Thoughts

  • Hot
  • Active