how do random numbers on computers work?

1.41K views

For example, is there a formula for a random number?

In: 47

75 Answers

Anonymous 0 Comments

Most computer applications use what is known as psudo random numbers. That is what you describe. There are a number of formulas which can generate an endless stream of what looks like random numbers. But of course they are not completely random as if you know the number it starts with or can guess this you can determine what the entire stream of numbers will be. But for most purposes this is enough.

True random numbers is a big problem for a computer. A lot of times you can gather random numbers by looking at the timings for the inputs, for example keyboard presses, mouse movements, network traffic and disk timing. If you take all these numbers and feed them into an algorithm which scrambles them together you get something which is very hard to guess.

For servers, virtual machines and various embedded devices this is hard though as they might not have much inputs, or even worse they might have predictable inputs. A common trick is to use the different timings from the two clocks in the computer. Most computers have one clock to keep track of time over hours, days and months and another to keep track of the timings of the signals in milliseconds, microseconds and even nanoseconds. And even though these are kept in sync with each other they are not perfectly aligned. So it is impossible to say for example who will count to a millisecond first when you start them the same time. This gives you some random numbers which can be used by the computer.

But it is becoming more and more common for computers to come with dedicated random number generator hardware. These contain a tiny bit of radioactive material, just a fraction of what your fire alarm contain, and then measures the random radioactive decay from this which it transforms into a stream of random numbers. There are other techniques which requires even less radioactive material but these are considered less secure. The random number generators often come included with the encryption module that is the trusted platform module.

You are viewing 1 out of 75 answers, click here to view all answers.