If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Pseudorandom number generators

Random vs. Pseudorandom Number Generators. Created by Brit Cruise.

## Want to join the conversation?

• In java programming if you are familiar, the random number generator built in with java generates a pseudo-random number. Why does Java not simply analyze one of the electrical ports on the computer and generate random numbers based on the static from that, like shown in the video? I feel like this would be much safer than simply using a pseudo-random number, because it would be easier to crack as a pseudo-random number as shown in the video, right?
• The sensors for measuring noise are not built into the computer. The computer senses much larger differences in noise, not the minuscule waves that you see in ports. And if we did, it would take up alot more CPU space than deemed acceptable/
• What's the difference between randomness and complexity?

And, along the same lines, what makes the physical world random and not complex?
• I have the same question. Isn't the world also deterministic if we take account of ALL factors that influence a certain situation? Like, we can considere each molecule. We can predict the result of rolling a dice after throwing it and before it stops if we consider all factors (air circulation and resistance, whirls and so on, I'm not a physicist :P), can't we?
• When you measure the "Randomness" of a pile of leaves and get a number, are you not getting randomness, but the sum of everything that happened to each of the leaves until they got to that point?
• Yes, things happened to the leaves to get them there, but we have no idea what happened to get them there so from our point of view it is random.
• If Eve knows the seed size and how many numbers constitute "the middle" of its square, couldn't she be able to find the initial seed (and thus the whole pseudorandom sequence) just by intercepting somehow the beginning of the pseudorandom sequence?
• From the author:Yes, if the seed size is small then many attacks such as these are easy. However if the seed size is 256 bits long, then there would be a massive number (on the scale of the size of the universe) to check.
• So what if you used a single large prime number? Would that increase the length of time it takes to see a repeating pattern?
• No, a prime would be the same as any other large number, because there is no need for multiplying to the seed. You only need to get the middle of the seed. No, I don't think it would, unless the middle of your number was a prime, then it might help a little bit.
• At , how did the narrator calculate the reduced key space to be 10k different outcomes only given it was generated from a 4 digit seed?
• Each diget has 10 posibilities. 10x10x10x10=10000
(1 vote)
• I was wondering if 10 sided dice numbered 0-9 rolled multiple times to generate the seed would work well? From what I understand 10 sided dice are a pentagonal trapezohedron with 2 sharp corners at the end. The odd numbers are usually labeled on one corner and the even labeled on the other.
• That would generate a number from 0 to 9,999,999,999. Depending on how many random numbers you want to generate and how frequently, this would come close to giving you a sequence of random numbers. Because you are computing the next random number from the last number, you would eventually repeat the sequence. Just as in the video, when you speed up the computations and plot them then a pattern emerges.
• what if you used an eternal number like Pi?
• That might work, except the problem is, you can't really square pi and have the computer remember infinite digits.
• Interesting discovery Alexander Strzalkowski, (look in comments) Can anyone explain it? Is it just a flaw?
• From the author:If you look closely, it actually does move but it has a very short period and loops around the origin back and fourth in a straight line. The red line quickly overlaps it so it's difficult to see this.
• This is cool, I am the first one to ask a question on this video

Why can't someone just measure TV static in order to generate a random number?
• You can. However, as stahl.ej already mentioned, it would not be very practical.

The main reason for generating a long series of random or pseudorandom numbers is to encrypt data. You need a long series to avoid repetition which makes the encryption easier to break.

The difficulty is if you need to encrypt some data and send it to someone else in a way that will put it at risk of eavesdropping. If you generate a truly random series of numbers to use as the encryption key, then you need to send the entire series to you recipient. Also, you cannot simply send it as is or the eavesdropper with see both the encrypted data and the encryption key and be able to decrypt the data. This is why methods like public key encryption are used.

In public key encryption with the use of pseudorandom numbers, the relatively short seed can be securely shared (see the video on public key encryption) and then used to generate the exact same very long encryption key on both sides of the secure conversation.

So, you could generate a truly random encryption key from TV static, but it would have to be shared ahead of time.