30.

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


Chapter 3
Keyword-Based Monoalphabetic Substitution

Using the information presented in Chapter 2, Monoalphabetic Substitution Concepts, as a base, this chapter continues the examination of monoalphabetic substitution techniques. This discussion opens with the development and use of a keyword-based mixed alphabet to add a degree of randomness to the development of plaintext and ciphertext alphabets. This will be followed by a discussion of several additional techniques that can be used to develop a ciphertext alphabet. Similar to the material presented in Chapter 2, you will examine different techniques and develop a series of subroutines and programs in Microsoft Corporation’s QuickBASIC and C++ programing languages to automate the operation of each technique.

Keyword-Based Mixed Alphabets

The relationship between plaintext and ciphertext alphabets in which one alphabet is shifted from the other by n positions is easy to construct. Unfortunately, it also represents an encipherment method that offers a very limited degree of protection to a message that falls into the hands of the wrong party. To add an additional level of protection to messages, keyword mixed alphabets were developed.

Construction

In a keyword mixed alphabet, a word or phrase is selected as the keyword and is used for the formation of the letters of the alphabet, with repeated letters omitted after their first occurrence. At the end of the word or phrase, the remaining letters of the alphabet are used in their normal sequence, omitting letters previously used in the keyword or phrase. For example, suppose you use the phrase GOD SAVE THE QUEEN as a keyword phrase. The first step in this process is to group the phrase to form a continuous word and eliminate duplicate letters in this newly formed word. This would result in the keyword GODSAVETHQUN, since there were duplicate E’s in the keyword. Next, you would add the letters of the alphabet to the keyword you just reduced to contain only one occurrence of each letter. This would result in the keyword-based mixed alphabet GODSAVETHQUNBCFIJKLMPRWXYZ.

Automating Keyword Construction

Listing 3.1 illustrates the statements in the program WORD.BAS which, when executed, produces a keyword-based mixed sequence alphabet. This program contains two subroutines—INITIALIZE and KEYWORD. The first subroutine is the same subroutine previously used in the CIPHER series of programs developed in Chapter 2 to initialize the PLAINTEXT array. The second subroutine was developed to produce a keyword-based mixed sequence alphabet. In this section, the focus is upon the subroutine labeled KEYWORD which actually forms the keyword-based mixed sequence alphabet. After a review of the operation of this subroutine, I’ll show you how to incorporate it into a new series of programs which will enable you to create both keyword-based mixed alphabets as plaintext and ciphertext alphabets, and to incorporate a shift key character to encipher a message.

Listing 3.1 The WORD.BAS program listing.

 REM PROGRAM WORD.BAS TO DEVELOP ALPHABET BASED ON A KEYWORD DIM PLAINTEXT$(26), CIPHERTEXT$(26), KEY$(26)   GOSUB INITIALIZE   INPUT "Enter keyword in CAPS", TEXT$   GOSUB KEYWORD   PRINT "Keyword-based alphabet is:"; X$   STOP INITIALIZE:   REM Initialize plaintext values   FOR I = 0 TO 25   READ PLAINTEXT$(I)   NEXT I   DATA "A","B","C","D","E","F","G","H","I","J","K","L","M","N"   DATA "O","P","Q","R","S","T","U","V","W","X","Y","Z" RETURN KEYWORD:   REM Place entered keyword into KEY$ array 1 character per position     MSGLEN = LEN(TEXT$)     FOR I = 1 TO MSGLEN     KEY$(I) = MID$(TEXT$, I, 1)     NEXT I   REM ELIMINATE DUPLICATE LETTERS, REPLACE WITH NULLS     K = 2     FOR I = 1 TO MSGLEN     FOR J = K TO MSGLEN     IF KEY$(I)  KEY$(J) GOTO NOTDUP     KEY$(J) = " " NOTDUP:    NEXT J     K = K + 1     NEXT I   REM REMOVE NULLS IN STRING     X$ = ""     FOR I = 1 TO MSGLEN     X$ = X$ + LTRIM$(KEY$(I))     NEXT I   REM PLACE REVISED KEYWORD WITH NO DUPLICATE LETTERS BACK IN KEY$     FOR I = 1 TO LEN(X$)     KEY$(I) = MID$(X$, I, 1)     NEXT I   REM COMPARE KEY$ & PLAINTEXT$ ARRAYS, BLANK PLAINTEXT$ WHEN MATCHED     FOR J = 1 TO LEN(X$)     FOR K = 0 TO 25     IF KEY$(J) = PLAINTEXT$(K) THEN PLAINTEXT$(K) = " "     NEXT K     NEXT J   REM CREATE ONE STRING     FOR I = 0 TO 25     X$ = X$ + LTRIM$(PLAINTEXT$(I))     NEXT I   REM PLACE SEQUENCE BACK INTO PLAINTEXT$ ARRAY     FOR I = 0 TO 25     PLAINTEXT$(I) = MID$(X$, I + 1, 1)     NEXT I RETURN END 


The use of a mnemonic key to mix a cipher alphabet can be traced to a family of cryptologists that lived in Rome during the sixteenth century. One member of this family, Matteo Argenti, served as the papal secretary of ciphers under Pope Gregory XIV and five succeeding popes. Argenti taught cryptology to his younger brother, Marcello, who served as a cipher secretary to a cardinal and wrote a cryptology manual which contained the first written reference to the use of a mnemonic key to mix a cipher alphabet.

The first keyword mixed alphabet developed by the Argenti family used numerics in place of ciphertext characters. To increase the difficulty of unauthorized decipherment operations, the letters “q” and “u” were merged into a single unit for encipherment and rules prohibiting word separations and punctuation were developed.



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