Previous | Table of Contents | Next |
You can easily construct a program to decipher messages previously enciphered through the use of an interval extraction, simple transposition, or numeric transposition sequence used to form a cipher alphabet. In doing so, you can use the subroutines contained in the previously created DCIPHER5.BAS program, change the main portion of the program to reflect the selection of one of the three decipherment techniques under consideration, and add the subroutines INTERVAL and TRANSPORT. The resulting programs, which are contained on the files DCIPHER6.BAS and DCIPHER6.CPP on the companion CD-ROM, are named as such since they are to be used to decipher messages previously enciphered through the use of the CIPHER6.BAS and CIPHER6.CPP programs.
Listing 4.8 lists the statements in the main program of the DCIPHER6.BAS program. You should note that the main portion of DCIPHER6.BAS is almost an exact duplicate of CIPHER6.BAS, with the differences between programs related to the use of the term decipher in place of encipher and the inclusion of the subroutines DMSGFILE and DCONVERTSTORE in place of MSGFILE and CONVERTSTORE. As explained previously, the prefix D on a subroutine is used to indicate a modification to a previously developed subroutine which results in a deciphering operation in place of an enciphering operation. Similar to other programs in this chapter, a comment consisting of five asterisks is used to indicate an extraneous PRINT statement included for explanation purposes but which can be removed from the program if you so desire.
Listing 4.8 The main portion of the DCIPHER6.BAS program.
REM PROGRAM DECIPHER.BAS DIM PLAINTEXT$(92), CIPHERTEXT$(36, 92), KEY$(92) CLS PRINT "DECIPHER.BAS PROGRAM deciphers text based upon the use" PRINT "of enciphering techniques contained in the book:" PRINT "ELECTRONIC MAIL PRIVACY:USING PRACTICAL ENCIPHERING TECHNIQUES" PRINT PRINT "This program supports the use of upper and lower case letters," PRINT "digits, punctuation characters and other characters whose ASCII" PRINT "values range between 32 and 128, but EXCLUDES the use of the" PRINT "foward slash (/), backslash (\) and double quote characters." PRINT PRINT AGN1: INPUT "Enter your secret code (6 characters required): "; CODE$ IF LEN(CODE$) = 6 THEN GOTO OK CLS PRINT "Your secret code must be 6 characters - please try again" PRINT GOTO AGN1 OK: CLS GOSUB INITIALIZE 'initialize plaintext values GOSUB SETUP 'obtain random seed and position in seed GOSUB DMSGFILE 'assign I/O files, place message on a file GOSUB KEYWORD 'form keyword based alphabet of 96 characters GOSUB PFORMCIPHER 'create 36 cipher alphabets GOSUB RDCONVERTSTORE 'convert and store ciphertext on a file GOSUB PRTOUT 'print results STOP
To illustrate the use of DCIPHER6.BAS, lets execute CIPHER6.BAS. Figure 4.9 illustrates the plaintext message and its resulting enciphered message when an interval extraction sequence of 3, keyword of MAYDECEMBER, and alphabetic shift key of B are used to form the shifted keyword mixed alphabet.
Figure 4.9 Enciphering a sample message using the CIPHER.BAS program.
Figure 4.10 illustrates the use of the DCIPHER6.BAS program to decipher our previously enciphered message. Note that the message recipient must know the type of technique used to encipher the message, the keyword or keyword phrase, and the alphabetic shift key. In addition, when an interval extraction technique is used, the recipient must also know the interval used for extraction.
Figure 4.10 Deciphering the message created using CIPHER6.BAS through the use of the DCIPHER.BAS program.
Because the author of this book is not a good typist, file input was selected in place of keyboard input. Because the program was created using the same PRTOUT subroutine used by enciphering programs to display the resulting deciphered message, that message is displayed in groups of five characters.
The inclusion of PRINT statements to display the four alphabets developed by the program can be used to trace the operation of the program. In addition, you can use the positional relationship between the plaintext alphabet characters and the characters in the shifted keyword mixed alphabet to verify the deciphering of the message contained in Figure 4.9 into the plaintext shown at the bottom of Figure 4.10. For example, the first group of five enciphered characters in Figure 4.9 is YOUGI. Locating Y in the shifted keyword mixed alphabet in Figure 4.10 and reading upward to the plaintext alphabet results in the extraction of the character P. Similarly, O becomes L, U becomes E, G becomes A, and I becomes S. Thus, if you desire you can easily verify the operation of the program. Once you are satisfied with its operation or do not wish to probe its operation, you can remove the extraneous print statements that display the different alphabets.
Previous | Table of Contents | Next |