Random Numbers

Started by
13 comments, last by Russell 22 years, 9 months ago
I have been reading about methods of encryption, and I have read about the value of a sequence of truly random numbers (or letters) used as a key to encrypt something. I''m curious if there are any methods for a computer to generate truly random numbers. I realize that if you call random() that it may appear random, but that it is really not random at all, it is only a function of the seed that you give it, and if you know the seed, it''s easy to predict the next number. So I''m curious about a few things. Is there any way for a computer to generate completely random numbers? And, is there any method of taking a sequence of values and determining their randomness (perhaps some kind of data analysis or pattern recognition)? Thanks, Russell
Advertisement
I''ve heard of some company that has rigged a CCD camera (digital camera) that takes periodical pictures of a bunch of lava-lamps and then they use those pictures as a key
This would generate truly random numbers since the fluctuations within a lava-lamp is very unpredictable.
I read an article that said recording background noise to a .wav file is a good way to generate psuedo-pure-random numbers, and that there is only a small bit of "purifying" that needs to be done to make this process truly random. He didn''t go into any detail about how to do this though. So I wonder how you would use the data in the .wav file, or how you would go about "purifying" it once you obtained it. I would assume that the method he was describing was to simply leave a microphone open and let it record nothing for a while.
Conceptually, it''s actually QUITE simple to create random numbers on a computer. You just have to base the numbers returned on a nondeterministic input source. Two very large nondeterministic input sources are the keyboard and the mouse.

Just generate the random numbers from some part of the input... Like drawing a single bit from the low order bit of the number of microseconds between key hits. Similar things can go for other nondeterministic sources, like the mouse, or even a network card on a busy network.
This is all a bit philosophical, since it is quite easy to argue that there is no such thing as 'truly random' as the entire universe is deterministic.

All I can suggest is to get a good pseudo random number generator (ie. not rand() in most C implementations), and seed it well.

As for analyzing data to see if it's random... well the simplest is a frequency analysis. Do some numbers in a sequence come up more than others? Do some ranges of numbers come up more than others? You can then take this to the next level... how frequently does 1 number follow another? And so on. Perhaps looking on some statistics sites would turn something up.

Edited by - Kylotan on June 28, 2001 2:49:17 PM
Using the actual definition of randomness, there are some tests that can be run against a list of numbers to judge how "random" they are. A couple go like this:

Odds/Evens Test -- The number of even numbers should be equal to the number of odd numbers.

Sums Test -- The number of even sums should equal the number of odd sums. (sums = the sum of any two consecutive numbers)

There are also tests regarding runs of numbers (consecutive numbers that increase by 1 for each number -- 1,2,3,4,5,etc..), and many other properties of the list of numbers.

Just thougt it might be interesting/helpful info.
quote:
I've heard of some company that has rigged a CCD camera (digital camera) that takes periodical pictures of a bunch of lava-lamps and then they use those pictures as a key
This would generate truly random numbers since the fluctuations within a lava-lamp is very unpredictable.


You're probably talking about SGI's Lavarand.

Edited by - Muzzafarath on June 28, 2001 3:03:20 PM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
There is a statement in Visual Basic "Randomize Timer", which if I remember correctly performs a certain function on the generated number based upon the first digit (one, two, three...) in the processors current tick count (milliseconds). ie... tick count 1,405,501 will perform a certain function (mathmatical) and 1,405,502 will perform a different function to the generated number. This however would require a little work in C/C++ but is the closest to random that I can think of. Other than seeding numbers from the tick count. That might work, I'm not proficient enough in C++ to be able to make that determination yet.

Edited by - Daishi on June 28, 2001 8:59:33 PM

I know only that which I know, but I do not know what I know.
quote:Original post by Daishi
There is a statement in Visual Basic "Randomize Timer", which if I remember correctly performs a certain function on the generated number based upon the first digit (one, two, three...) in the processors current tick count (milliseconds). ie... tick count 1,405,501 will perform a certain function (mathmatical) and 1,405,502 will perform a different function to the generated number. This however would require a little work in C/C++ but is the closest to random that I can think of. Other than seeding numbers from the tick count. That might work, I''m not proficient enough in C++ to be able to make that determination yet.

Edited by - Daishi on June 28, 2001 8:59:33 PM


Randomize Timer is essentially the same as srand(time(NULL)) in C/C++. While these will work relatively well for games and purposes like that, the sequence you will get are not truly random. They appear to be random, but if you know how the sequence is calculated, you can compute the entire sequence from just one seed value. Probably not a good thing for encryption.
Scientifically speaking, nothing is random. Everything is based on specifically defined rules and formulas.

(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)

This topic is closed to new replies.

Advertisement