Randam numbers
May 2, 2008 by littlewingpinball
An unbreakable encryption has got into the news in Japan recently. I checked the topics to see what’s going on as it roused my attention.
There is a famous encryption called one-time pad which lots of blogs talk about. It is proved to be unbreakable. But at the same time, it is a simple one. For example, to encrypt HELLO to WORLD, it uses a randam number which length is the same and the randam number should be used just one time.
In the process of the decryption of WORLD(encrypt) to HELLO(plaintext), there will be bunch of candidates such as WORLD>BREAD, WORLD>NORTH. The right answer could be included in the candidates, but it will be shown in the candidates without any hint. Therefore, a decrypter never knows what is the right answer even if he’s seen the right answer. That means, the right plaintext is not necessary to be hidden from the decrypter.
Another example. Provided you want to decrypt an encrypted girl’s name. It is possible to input information such as “the plain text is a girl’s name” along with the table of all girls name and round-robin randam numbers… but it will work only to display all girls name on the screen. This can’t break the encryption.
It is important to use the same length randam number only one time. You can use the same randam number repeatedly so that you can get closer to the answer.
Well, the randam numbers. To create them in a program is a tricky job. Using only software, we can generate only false randam numbers. It is because running a same program generates same randam numbers everytime. If you have a trouble with this, you can use built-in clock or counter of CPU or other special hardware devices.
In the game programming, you can use input timing of the user as an element so that the performance of randam numbers is usually fine. But in some occasion, you may see stripes on the screen which is created by the “false” part of the randam numbers.
In such case, I create my own randam number generating algorithm for better performance. I noticed randam numbers of C library often causes such problems as it considers the speed to be most important.
To be randam is not simple as it looks.
Reference: one-time pad, Mersenne twister (Wikipedia)