How do computers generate random numbers?
A modern &quot;pseudo random number&quot; is simply a sequence of numbers that visits the state-space in an order that&#x27;s difficult to detect with modern statistical tests. (Chi-squared, among others). See PractRand or TestU01 as two packages for testing these sequences. That is to say: instead of the sequence &quot;0, 1, 2, 3, 4, 5... 4294967296... 0&quot;, your RNG will do some other sequence.<p>Yes, &quot;0, 3, 6, 9... 4294967295, 2, 5, 8... 4294967294, 1, 4, 7... 4294967293, 0, 3...&quot; is a RNG of sorts, but an example of a really, really bad one that would instantly fail most statistical tests. :-) But conceptually, the Mersenne Twister, LCGRNG, and LSFR all accomplish this. Its a &quot;reordering&quot; of the sequence. That&#x27;s it.<p>A &quot;cryptographic random number&quot; just adds a few additional tests to the pool of statistical tests. In particular: differential cryptography gets into the nitty gritty about which bits can predict the results of other bits. You have to assume that the &quot;opponent&quot; is willing to use extraordinary amounts of computing power to detect patterns.<p>If bit#25 has a 51% correlation with bit#30, you fail cryptographic random numbers. You need to be within 2^128 (at least) worth of security or more. That means a near 50% correlation (maybe 50.00000000001% is fine) between bits and future bits.<p>For example: the sequence: {AES(0, key), AES(1, key), AES(2, key)... AES(2^128, key), AES(0, key)...} is a cryptographically secure random number generator. The sequence will loop after its 128 bits of state are exhausted. If the &quot;opponent&quot; doesn&#x27;t know the key, the bitwise correlations are cryptographically sound (thanks to the hard work of the engineers behind AES).<p>A true random number generator is just a cryptographic number generator applied to a truly random seed. White noise generators are a well known electronic-engineer trick: resistor noise is everywhere but is rather small (but you can build a white-noise generator from Johnson Nyquist noise if you really wanted). More likely, you use shot-noise from a transistor junction, at least at the hobbyist level.<p>Intel &#x2F; AMD have true random number generators from some kind of electrical noise generator on every CPU, which feeds into cryptographic random number generators.<p>There are other sources of noise: radiation is a well known one but I&#x27;m not sure if they&#x27;re practical.<p>There&#x27;s a &quot;speed limit&quot; to white noise generators. You only can extract so much entropy from them in a given time (ex: Remember: CPUs operate at 4GHz, or 0.25 nanoseconds per clock tick). Cryptographic random number generators &quot;stretch&quot; the true seed of randomness, while the white-noise generator continues to grab more entropy.