69.

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


Listing 6.12 The ASCII.CPP program listing and sample execution.

 /* ASCII.cpp C++ code written by Jonathan Held, May 8, 1998, using Microsoft's Visual C++ version 5.0. */ #include <iostream.h> #include <string.h> #include <iomanip.h> //---------------------------------------------------------------- //Function: main() //Parameters: None //Return Type: int - 0 means program terminated normally, any other //value indicated abnormal termination //Purpose: Runs the main part of the program. //---------------------------------------------------------------- int main(){   char buffer[1000];   const char *spacing = "              ";   cout << "Use CTRL-C to terminate program." << endl << endl;   while(true){    cout << "Enter a sequence of characters: ";    cin.getline(buffer, 1000, '\n');    cout << endl << "ASCII values: ";    int ix = strlen(buffer);     for (int jx=0; jx<ix; jx++){      if ((jx!=0) && (!(jx%10)))         cout << endl << spacing;      cout << setw(3) << (int) buffer[jx] << " ";     }     cout << endl << endl;   }  return 0; }//end main() //end file listing C:\>ASCII Use CTRL-C to terminate program. Enter a sequence of characters: 12 ASCII values:  49  50 Enter a sequence of characters: 1 2 4 6 ASCII values:  49  32  50  32  52  32  54 Enter a sequence of characters: A B C D ASCII values:  65  32  66  32  67  32  68 

At this point it may be useful to examine a six-position code used to perform a series of manipulations to obtain a position within a random number seed. Although I will review one series of manipulations, a six-character code provides 6!, or 720, possible methods by which the characters can be used if they are used one character at a time. If you desire, you can change the method of code character manipulations to fit your specific requirements.

To manipulate the six-position code, first multiply the ASCII value of each of the first two characters in the code to use as the RANDOMIZE seed setting. Next, multiply the ASCII values of the third and fourth characters in the code to serve as a first limit for entry into a position within the selected seed. Use the ASCII value of the fifth code character to increment towards the limit. As a further offset into the random number sequence, multiply the ASCII values of the fifth and sixth code characters and use the result as a second limit. Then, sequence towards that limit using the ASCII value of the fourth code character as a mechanism for incrementing towards that limit.

The use of the six-character grouping we previously discussed is illustrated graphically in Figure 6.3. An analysis of the combinations obtained from the use of that code is warranted, as it indicates how good intentions can go astray and why many persons throughout the history of mankind have become so involved in developing “unbreakable” techniques that they literally couldn’t see the trees in the forest and did not understand the weakness they created in their quest for increasing the complexity of their code design.


Figure 6.3  Using the code characters.

In Figure 6.3 the use of a two-character position to generate a seed setting when each position is restricted to alphanumeric characters reduces the number of seed combinations to 362, or 1,296, which is significantly less than the maximum number of seed settings supported in BASIC. The entry into the selected seed is based upon the multiplication of the value of code positions three and four, which are added to the product of the values of code positions five and six. This means that the maximum value of the displacement into the selected seed is 2,592 positions when code positions are limited to alphanumeric characters. Thus, the maximum number of combinations one has to try in an attempt to locate the position within a selected seed for enciphering a message becomes 1,296 seeds * 2,592 positions, or 3,359,232 combinations! Although this is still a formidable number, it is certainly less formidable than the maximum number of combinations that can be obtained from a six-character position code. You may wish to consider alternative methods to use the characters in a code to initiate a random number sequence within a seed at a defined position. Later in this chapter I will discuss an alternative method you can consider for the use of the characters in a code to initiate a sequence of random numbers. However, for the moment I will focus on the way you can code the previously described code character manipulations for use in programs that encipher and decipher messages based upon the use of the built-in BASIC random number generator. I will also develop programs that will accept any ASCII character in each code position. This will significantly extend the number of possible combinations others must try in an attempt to decipher a message enciphered through the use of the program RANDOM3.BAS developed later in this chapter. For example, with each character code position capable of containing any conventional ASCII character, the use of code positions one and two for selecting the seed increases the number of seeds capable of being used to 127 * 127, or 16,129. Once you have an appreciation for the coding and operation of “secret” code-based programs, you will learn how you can make those “secret” codes even less vulnerable. Following our customary method, once I describe a BASIC program, I will then indicate the appropriate C++ program.


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