It doesn’t. Computers use what’s called psuedorandom numbers. Basically, it is a very complex algorithm that takes in a big number as what we call a seed, and it uses that generate the random number.
However, if you call the random number function with the same seed every single time, it will generate the same sequence of random numbers every single time.
Sometimes, this is done with the system time as the seed, but again, you can call the function with the exact same system time and get the same number. If that random number needs to be unpredictable, this is unacceptable (like encryption).
For truly random numbers, we have a facility in California run by a company called Cloudflare. In this facility there is a wall of lava lamps with a camera pointed at them, and when someone needs a truly random number, they send a request to Cloudflare. Their camera takes a picture of the lava lamps, and uses the position of the lava to generate a random number.
No one as a computer powerful enough, nor knows the initial conditions of these lava lamps well enough simulate the lava lamp wall accurately enough for anyone to predict the random numbers generated, so these random number are secure.
Latest Answers