67.

Learn Encryption Techniques with BASIC and C++
(Publisher: Wordware Publishing, Inc.)
Author(s): Gil Held
ISBN: 1556225989
Publication Date: 10/01/98

Previous Table of Contents Next


Extending the Combinations

You can substantially increase both the number of combinations available for starting the random number sequence to be used in a program as well as the speed in which the user of the program obtains access to the sequence. To accomplish this, use a third key to increment the FOR-NEXT loop to both speed up the positioning process as well as increase the number of combinations an unauthorized party must try in an attempt to decipher an enciphered message.

The top portion of Listing 6.10 contains the program listing for entering a three-number sequence to select a position within a random number sequence defined by a random number seed from which to commence the encipherment process at the next random number position. In this example, the first number is assigned to the variable x, and is used to select the random number seed sequence. The second number entered is assigned to the variable y and defines the limit of the FOR-NEXT loop. The value of the third number entered is assigned to the variable z and defines the increment used in the FOR-NEXT loop. Each of the numbers can be considered to represent a key. You can consider this elementary program a random number generator based upon the use of a three-numeric key sequence.

Listing 6.10 Sample program that uses three numbers to rapidly position the starting point within a random number sequence of a defined random number seed.

 INPUT "Enter your three key numbers, each separated by a comma: ",x,y,z RANDOMIZE (x) FOR i = 1 to y STEP z dummy = RND NEXT I FOR I = 1 TO 10 PRINT INT(RND * 100) NEXT I PRINT Enter your three key numbers, each separated by a  comma: 12,24,4  1 87 10 94 95 82 26 71 21 57 Enter your three key numbers, each separated by a  comma: 12,24,9  50 27 89 1 87 10 94 95 82 26 Enter your three key numbers, each separated by a  comma: 12,240,9  31 88 52 70 32 72 70 37 95 12 Enter your three key numbers, each separated by a  comma: 12,110543,43  3 3 17 51 70 18 51 35 79 27 Enter your three key numbers, each separated by a  comma: 110543,1993,12  65 34 48 63 89 66 63 2 41 29 

The lower portion of Listing 6.10 illustrates the results obtained from executing the program five times in sequence using different key combinations.

The first two examples illustrated at the bottom of Listing 6.10 could have used the month and day of the month for the first two keys and an hour for the third key. The third example could have used the Julian day for the day instead of the day of the month. In the fourth example, the second key could be a person’s date of birth. In the fifth example, perhaps the first key is the person’s date of birth, while the second and third keys are the current year and month.

Regardless of the manner in which values are assigned to each key, the use of three keys can provide an extremely large number of combinations. However, the key (no pun intended) to obtaining a large number of combinations is the mechanism used to generate key values. By selecting easy-to-remember but relatively large values for each of the three keys, you can force an unauthorized person with access to a deciphering program to obtain the power of a mainframe or modern Pentium II computer to decipher your message. For example, using a date in the form of mmddyy for the first key, a year in the form of yyyy for the second key, and a number in the form of dd for the third key could result in up to 10 billion possible combinations an unauthorized person obtaining access to an enciphered message might have to try in an attempt to decipher your message! Now that’s a significant order of magnitude beyond the 65,536 random number seed sequences and adds a degree of decipherment difficulty that corresponds to a level of protection afforded by many commercially available systems whose purchase price significantly exceeds the cost of this book.

Creating Your Own Random Number Generator

Although the preceding three key examples indicated a series of approximately 10 billion combinations would be required, when you use a built-in random number generator you simplify the life of code-breakers. This is because if they have a bit of knowledge concerning the random number generation scheme you are using, it is a relatively simple process to program a computer to cycle through every possible combination. Because of this, the use of a built-in random number generator entails a bit of a risk. Although it could take a long time to lock onto your random number sequence, who would have expected desktop computers to operate at 400 MHZ a few years ago? This means that the months, days, or hours of attack required today may be reduced to days, hours, or minutes tomorrow. Recognizing this fact, let’s examine how you can easily create your own pseudo-random number generator. Because there are an infinite number of equations you could use to create your own generator, doing so can make the life of a code-breaker significantly more difficult.

Because a pseudo-random number generator requires an equation, let’s define one. Let’s assume the following equation is your magic formula for generating a random number:

       INTEGER  MYRANDOM * 37 + 462               (        42         ) 

Although it may appear the preceding formula represents a randomly developed equation, let me explain its operation to shed light on how you can develop your own random number generator. If you assume that the variable MYRANDOM ranges between 0 and 100, then the maximum value of the preceding formula becomes:

       INTEGER    100 * 37 + 462   or 99                 (       42     ) 

Thus, your magic formula would return values from 11 to 99, as when MYRANDOM has a value of zero the formula returns a value of 11.

To use a magic formula, you could accept a number from the keyboard and assign its value to the variable MYRANDOM. After computing a pseudo-random number, you could both use that number and assign its value to MYRANDOM to generate a second pseudo-random number. For example, assume you entered 10 from the keyboard. The first time the magic formula is computed you would obtain:

       INTEGER    10 * 37 + 462    or 19                 (       42    ) 

Using 19 as input to the formula, you would obtain:

       INTEGER    19 * 37 + 462    or 27                 (       42    ) 

Although the preceding magic formula was rather simplistic, it illustrates how you can create your own pseudo-random number generator. In concluding this chapter, I’ll illustrate the creation of a program to generate pseudo-random numbers without using a language’s built-in random number generator function.


Previous Table of Contents Next


Learn Encryption Techniques with Basic and C++
Learn Encryption Techniques with BASIC and C++
ISBN: 1556225989
EAN: 2147483647
Year: 2005
Pages: 92
Authors: Gil Held

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net