15.

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


Alphabetic Relationships

The top portion of Figure 2.1 illustrates the elementary relationship between a direct-sequence plaintext alphabet and a direct-sequence ciphertext alphabet. In this example, the ciphertext alphabet was shifted or wrapped five character positions to the right with respect to the plaintext alphabet if the wraparound of each character is considered to represent one positional shift. As you will shortly note, the relationship between the numeric positions representing a ciphertext character (C) and a plaintext character (P) can be expressed as C=(P+5) modulo 26.


Figure 2.1  Plaintext-cipertext relationship.

To illustrate the relationship between ciphertext and plaintext characters, assume each of the letters of the plaintext alphabet is sequentially assigned the numbers 0 through 25. Then, the process of encipherment illustrated in the top portion of Figure 2.1 can be expressed as C=(P+5) modulo 26, where C represents the ciphertext character’s numeric value, P represents the plaintext character’s numeric value, and the modulo 26 process requires 26 to be subtracted when the result of the addition exceeds 25.

For example, 25 mod 26 has a value of 25, while 26 mod 26 and 27 mod 26 have values of 0 and 1, respectively. To verify this relationship, the lower portion of Figure 2.1 indicates the numerical relationships between the characters in the plaintext and ciphertext alphabets. The numeric relationship is based upon the assignment of the values 0 through 25 to the letters in the plaintext alphabet and the shifting of the ciphertext alphabet by five positions with respect to the plaintext alphabet.

From an examination of Figure 2.1, it becomes obvious that the ciphertext alphabet can be shifted up to 25 positions to the right or it can be reversed and shifted to the left. When directly shifted to the right, a series of 25 cipher alphabets can be developed, since the 26th shift results in the ciphertext matching the plaintext. Perhaps the most famous example of the use of a shifted cipher alphabet is the one credited to Julius Caesar in which the original displacement between plaintext and ciphertext was three places to the right. This well-known cipher, as well as other displacement ciphers, is very weak because the reconstruction of plaintext may be reduced to a simple trial-and-error process. However, because you need to start somewhere, this simple displacement process represents a good starting point for our discussion of monoalphabetic uniliteral substitution systems.

The recipient of a message encoded as a monoalphabetic uniliteral substitution system requires a mechanism to convert ciphertext to plaintext. That mechanism is obtained by knowing the displacement used to encode the ciphertext and using that displacement to reverse the process. Mathematically the process can be expressed as P=(C-n) mod 26, where P represents the plaintext character’s numeric value, C represents the ciphertext character’s numeric value, n represents the displacement used to encode the ciphertext, and the modulo 26 process requires 26 to be subtracted when the result of the addition exceeds 25.

You can use Figure 2.1 to illustrate encipherment and decipherment. For example, assume the message HELP was encoded using a displacement of 5. The resulting ciphertext you would receive would be MJQU. You could convert the characters to their numeric equivalents, resulting in the sequence 12, 09, 21, 25. As previously noted, P=(C-n) mod 26. Since the displacement is 5 positions (P=(C-5) mod 26), this results in the received sequence of 12, 09, 21, 25 being converted to 07, 04, 16, 20. In the plaintext line in Figure 2.1 the numeric sequence 07, 04, 16, 20 represents the characters HELP which represents the deciphered message.

Displacement Alphabets

As previously illustrated in Figure 2.1, you can develop a series of 25 direct ciphertext alphabets with respect to a plaintext alphabet when both are restricted to uppercase English letters. The top portion of Listing 2.1 contains a simple program named SHIFT.BAS which displays all possible displaced alphabets from the standard uppercase English alphabet. In this program, the string array PLAINTXT$ is used to store each letter of the alphabet through the use of a READ statement contained in the first FOR-NEXT loop. The following pair of FOR-NEXT loops causes 25 shifted alphabets to be displayed with respect to the original alphabet which is displayed without any shift occurring. The bottom portion of Listing 2.1 illustrates the result obtained from the execution of SHIFT.BAS.

Listing 2.1 The SHIFT.BAS program listing.

 Rem PROGRAM SHIFT.BAS Rem This program produces a sequence of shifted alphabets Cls Dim PLAINTXT$(26) For I = 0 To 25 READ PLAINTXT$(I) Next I Data "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K" Data "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" For J = 0 To 25 For I = 0 To 25 Print PLAINTXT$((I + J) Mod 26); Next I Print Next J ABCDEFGHIJKLMNOPQRSTUVWXYZ BCDEFGHIJKLMNOPQRSTUVWXYZA CDEFGHIJKLMNOPQRSTUVWXYZAB DEFGHIJKLMNOPQRSTUVWXYZABC EFGHIJKLMNOPQRSTUVWXYZABCD FGHIJKLMNOPQRSTUVWXYZABCDE GHIJKLMNOPQRSTUVWXYZABCDEF HIJKLMNOPQRSTUVWXYZABCDEFG IJKLMNOPQRSTUVWXYZABCDEFGH JKLMNOPQRSTUVWXYZABCDEFGHI KLMNOPQRSTUVWXYZABCDEFGHIJ LMNOPQRSTUVWXYZABCDEFGHIJK MNOPQRSTUVWXYZABCDEFGHIJKL NOPQRSTUVWXYZABCDEFGHIJKLM OPQRSTUVWXYZABCDEFGHIJKLMN PQRSTUVWXYZABCDEFGHIJKLMNO QRSTUVWXYZABCDEFGHIJKLMNOP RSTUVWXYZABCDEFGHIJKLMNOPQ STUVWXYZABCDEFGHIJKLMNOPQR TUVWXYZABCDEFGHIJKLMNOPQRS UVWXYZABCDEFGHIJKLMNOPQRST VWXYZABCDEFGHIJKLMNOPQRSTU WXYZABCDEFGHIJKLMNOPQRSTUV XYZABCDEFGHIJKLMNOPQRSTUVW YZABCDEFGHIJKLMNOPQRSTUVWX ZABCDEFGHIJKLMNOPQRSTUVWXY 


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