Cryptography > Substitution Ciphers (45 min.)  
Objectives:

1) Understand what Substitution Ciphers are and how they work. 

2) Distinguish between Mono- and Polyalphabetic Ciphers

3) Encrypt using the Caesar, the Atbash and the Playfair Cipher. 

3) Learn how to break Substitution Ciphers.


On this page I will introduce you to Substitution Ciphers. Instead of shuffling, we now substitute plain letters. Precisely: 

In Substitution Ciphers same plain letters are replaced by same cipher letters. 

On the previous page, we learned the weakness of transposition ciphers: The plain letters made up the cipher text. Thus, combining the cipher letters in a clever manner must yield the plain letter eventually. An attempt to improve the security level of the encrypted messages is to hide the plain letters by replacing them with other letters. Most of the ciphers in the tutorial are Substitution Ciphers. Therefore, I will be brief with the introduction of such Ciphers on this page. 

Example 1: (Caesar Cipher) The simplest of all substitution ciphers is the one in which the cipher letters results from shifting plain letters by the same distance. Among those, the best known is called "Caesar Cipher", used by Julius Caesar, in which each A is encrypted as D, B as E, C as F,... etc. 

Related web sources:

Enigma and the Codebreakers

Yahoo's Encryption & Security

Britannica.com

Dictionary.com

Glossary

PBS Online

Introduction to Cryptography

Enigma History

Enigma Emulator

 

 

 

     
 Plain text

 

Cipher text

 

 

 

   
Exercise 1: Use the Caesar Cipher to encode "A man a plan a canal" by hand. 
D pdq d sodq d fdqdo
Exercise 2: Decode the ciphertext "fdhvduvdodg" by hand.  caesarsalad

Example 2: (Atbash Cipher) Try to break the following monoalphabetic substitution cipher.  

     
 Plain text

 

Cipher text

 

 
 

If you are not successful, try to encode "abcd" and "xyz". Then continue reading. 

Did you notice that every A was replaced by Z, B by Y, C by X, D by W, etc. ? That simple. This cipher is called the "Atbash Cipher", a Hebrew Ciphering method. The Hebrew word "atbash" indicates the substitution method used: The first letter, Alef, is followed by the last, Taw. The second, Bet, is followed by the second last, Schin. The Atbash Cipher was used in the Bible where "Babel" was replaced by "Scheschach" using the appropriate substitutions of Hebrew letters.

Exercise 1: Encode "CRYPTOGRAPHY" with the Atbash Cipher by hand. Afterwards, verify your cipher text above. XIBKGLTIZKSB

Exercise 2: Decode "dszgrhhgvtzmltizksb" with the Atbash Cipher by hand. Afterwards, verify your plain text above.    whatissteganography

Exercise 3: Invent a Monoalphabetic substitution cipher. Encode "Learnyourabc" and pass the cipher text to your father or to your class neighbor to break it. I.e. Replace each A by B, each B by C, etc. Don't make it too hard on your father.  

In Substitution Ciphers, single letters or pairs of letters are replaced with symbols or groups of symbols, which need not be the same as those used in the plaintext.  Let me give you two examples:

Example 3: In Edgar Alan Poe's "The Goldbug", the hero Legrand solves the following monoalphabetic substitution cipher:

53++!305))6*;4826)4+.)4+);806*;48!8`60))85;]8*:+*8!83(88)5*!;
46(;88*96*?;8)*+(;485);5*!2:*+(;4956*2(5*-4)8`8*; 4069285);)6
!8)4++;1(+9;48081;8:8+1;48!85;4)485!528806*81(+9;48;(88;4(+?3
4;48)4+;161;:188;+?;    

Can you guess what Legrand's cryptoanalysis yields? Hint: Since the original was encrypted using a monoalphabetic substitution every symbol corresponds to a letter in the English language. Find out here how Legrand breaks it. Read "The Goldbug" here.


Example 4:
In Sir Arthur Conan Doyle's "Adventure of the Dancing Men", Sherlock Holmes has the pleasure of solving a monoalphabetic substitution cipher in which the ciphertext symbols were stick figures of a human in various dancelike poses.

 

Figure 1: "Dancing Men" - Every dancelike pose represents a letter used in the English language.

Read how Sherlock Holmes cryptoanalyzes in the "Adventure of the Dancing Men".

 

We will study three monoalphabetic ciphers in detail and learn that neither the cyclical-shift substitution ciphers nor any other monoalphabetic substitution cipher in which a given plaintext letter is always encrypted into the same ciphertext letter are secure. The explanation for this weakness (as you can read in the two novels mentioned) is that the frequency distributions of letters in the plaintext and in the ciphertext are identical, only the letters having been replaced. In fact, any given structure or pattern in the plaintext is always preserved intact in the ciphertext, so that the cryptanalyst's task is an easy one.

 

1. How can the Security of Substitution Ciphers be increased?

That is: "How can the letter frequencies and the structure of the plaintext be concealed?" There are two main approaches:
 
Approach 1: (Biliteral Ciphers) Instead of encrypting single letters we encrypt pairs (or even triples) of letters. The ADFGVX Cipher that you learned on the previous page is an example for Biliteral Ciphers. Although I introduced the cipher on the Transposition Cipher page, it is a Substitution Cipher. 

Approach 2: (Polyalphabetic Ciphers) Instead of replacing same plain letters by the same cipher letters we vary the replacement rule. Consequently, same plain letters may be encrypted to different cipher letters. When this "polyalphabetic substitution" is carried to its limit, it results in socalled "onetime pads", which are the only cryptosystems that can be proved to be secure. We will study them in detail aswell. 

 


English physicist and inventor Sir Charles Wheatstone (1802 - 1875)
Example for Biliteral Ciphers: (Playfair Cipher) The best known substitution cipher that encrypts pairs of letters is the Playfair Cipher invented by Sir Charles Wheatstone but championed at the British Foreign Office by Lyon Playfair, the first Baron Playfair of St. Andrews, whose name the cipher bears. Below is an example of a Playfair cipher, solved by Lord Peter Wimsey in Dorothy L. Sayers' Have His Carcase. Here, a  5 x 5-square matrix containing the 26 letters of the alphabet (I and J are treated as the same letter) is used to carry out the encryption. A key word, MONARCHY in this example, is filled in first, and the remaining unused letters of the alphabet are entered in their lexicographic order:



Pairs of plaintext letters are encrypted with the matrix by first locating the two plaintext letters in the matrix. They are 
(1) in different rows and columns or 
(2) in the same row or  
(3) in the same column or 
(4) alike. 

The corresponding encryption (replacement) rules are the following:
1. If the pair of letters are in different rows and columns, each letter is replaced by the letter that is in the same row but in the other column; i.e., to encrypt WE, W is replaced by U and E by G.

2. If two letters are in the same row simply shift both one position to the right. I.e.  A and R are in the same row. A is encrypted as R and R (reading the row cyclically) as M.

3. Similarly, if two letters are in the same column shift both one position down. I.e. I and S are in the same column. I is encrypted as S and S as X.

4. If a double letter occurs, a spurious symbol, say Q, is introduced so that the MM in SUMMER would encrypt into NL for MQ and CL for ME.

5. An X is appended to the end of the plaintext if necessary to cause the plaintext to have an even number of letters.

Encrypting the familiar plaintext example using Sayer's Playfair matrix yields:



Exercise 1: Encode "THE TREASURE WAS FOUND BY THE PIRATE" using the Playfair Cipher with the above keyword "MONARCHY". 
PDKLMKBXZMGUBXPHWMCDDQCFSFRMLK

Exercise 2:
Encode "THE TREASURE WAS FOUND BY THE PIRATE" using the Playfair Cipher with the keyword "SECRET".
SMCSTCHAQTBEHABQNOFDRZSIOKSFSC

Exercise 3: Decode "BKGHHVSEEBTCBQNOKC" using the Playfair Cipher with the keyword "SECRET".
DIAMANTS WERE FOUNDX

2. Biliteral Ciphers can be broken

Recall that the weakness of any Monoalphabetic Cipher is the transfer of the underlying letter frequencies. Is that true for Biliteral Ciphers aswell? Answer: Yes, but to a smaller degree. Here is why: Say the letter pair "HE" occurs frequently in a cipher text. About 50 out of 100 letter pairs "HE" are encoded to "CF" when using the above Playfair example. The 50% chance is due to the cutting process where pairs of letters are extracted from the plain text. If the "H" is at an odd position, they are encoded as a pair, otherwise not. Therefore, the frequency of plain letter pairs is watered, however, it is not lost. This is the essential structure exploited by a cryptanalyst in solving a Playfair cipher. The cryptoanalysis is certainly facilitated if a large piece of cipher text is available. The loss of a significant part of the plaintext frequency distribution, however, makes a Playfair cipher much harder to cryptanalyze than a monoalphabetic cipher.

Example for Approach2 - Polyalphabetic Ciphers: The other approach to conceal plaintext structure in the ciphertext involves using several different monoalphabetic substitution ciphers rather than just one; the key specifies which particular substitution is to be employed for encrypting each plaintext letter. In the simplest systems of the Vigenère type, the key is a word or phrase that is repeated as many times as required to encipher a message. The resulting ciphers, known generically as polyalphabetics, have a long history of usage. The systems differ mainly in the way in which the key is used to choose among the collection of monoalphabetic substitution rules.

The best known polyalphabetics are the simple Vigenère ciphers, named after the 16th-century French cryptographer Blaise de Vigenère. For many years this type of cipher was thought to be invincible and was known as le chiffre indéchiffrable. We will study the Vigenère Cipher in detail here after having studied three monoalphabetic ciphers. 

 

top

back  next