76.

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


After the first seed is selected using the RANDOMIZE SEED1 statement, use a two-step approach to position yourself into the random number sequence within the selected seed. First multiply the ASCII values of the first, third, and fifth characters in the “secret” code to serve as the limit for the first FOR-NEXT loop, assigning the value of the three products to MAX. The ASCII value of the second character in the “secret” code is used as the stepping increment through the FOR-NEXT loop.

To go further into the random number sequence, we use a second FOR-NEXT loop in which the ASCII value of the first character multiplied by 500 serves as the limit of the loop, and the ASCII value of the third character in the “secret” code functions as the stepping mechanism through the loop. Once your positioning is completed, extract 1,000 random numbers which are placed into the array R1.

Using the value computed for the second seed, use the statement RANDOMIZE SEED2 to select that seed. Next, use the ASCII value of the characters in the “secret” code to position yourself into a random number sequence in that seed. Multiply the values of the second, fourth, and sixth characters in the “secret” code to serve as a limit for the FOR-NEXT loop and use the value of the fourth character to step through the loop. To go further into the sequence, another FOR-NEXT loop multiplies the ASCII value of the fourth character by 8,307 and uses the ASCII value of the second character as a mechanism to step through the loop. This is followed by extracting 999 random numbers and placing them into the array R2.

When you examine the contents of the routine SETUP, note that both the ASCII value of the characters in the “secret” code word and the numerics entered in the program to govern the extraction process were used. You can use this subroutine as a guide to develop a random number extraction process that differs from the techniques presented in this book if you wish to obtain an additional degree of message security.

Once the subroutine SETUP is invoked, set the “paper tape” rotation scheme into operation by assigning the value 0 to the variable P1 and 1 to the variable P2. Then, for illustrative purposes, execute the subroutine ROTOR 500 times. If you were to use this subroutine to encipher a message, each time you invoke the subroutine, up to 999,000 times, you would receive a newly created random number whose value would be between 0 and 99. You must consider transmitting messages with less than 999,000 characters as well as the effect of adding a number with that possible variance to the set of values of plaintext characters you wish to encipher. For example, if 32 of the possible resulting character values are between 0 and 31, those enciphered characters become control characters that cannot be transmitted over 7-bit electronic mail systems. Another concern you should think about is the necessity to print copies of enciphered messages, because you cannot print control characters. You may wish to modify the ROTOR subroutine to produce random numbers within a range of values which, when added to the ASCII value of the supported set of plaintext characters, permits transmission over 7-bit electronic mail systems and printing of enciphered messages.

The first statement in the subroutine ROTOR adds the random numbers in the arrays R1 (0) and R2 (1), multiplies the result by 100, performs a modulo 99 operation, and extracts the integer result. After the value of R is printed, the value of P1 which represents the position in the first random number sequence is incremented by 1. Only after all 1,000 random numbers in the array R1 have been added using the first random number in R2 do you re-sequence or rotor the “paper tape.” Here, when P1 equals 1,000 we increment P2 by 1 and reset P1 to 0. Each time the subroutine ROTOR is invoked you would continue this process.

To illustrate the result of the previously described set of routines, Figure 6.8 contains the random numbers generated from the execution of ROTOR.BAS. In this example, the secret code ROUTE9 was used to generate the sequence of 500 random numbers generated by the program.


Figure 6.8  Execution of ROTOR.BAS using the secret code ROUTE9.


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