You are on page 1of 37

Substitution Ciphers

1
Substitution Ciphers
• Monoalphabetic cipher
• Caesar cipher
• Polyalphabetic cipher
• Vigenère cipher
• Multiple letter cipher
• Playfair cipher

2
Monoalphabetic cipher
• Plaintext characters are substituted by a different
alphabet stream of characters shifted to the right
or left by n positions
• E.g., ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
• Caesar cipher corresponds to n = 3
• Julius Caesar used the Caesar cipher method

3
Monoalphabetic cipher
• The substitution cipher by shifting alphabets gives
26! > 4 x 1026 possibilities
• This might appear to be too many choices to try for
an exhaustive attack
• This is a weak cipher because it would be easy to
guess the pattern
• Mono-alphabetic ciphers are vulnerable to
cryptanalysis attack

4
Monoalphabetic cipher
• The shift pattern above could be replaced by
random assignment of characters for each alphabet
• E.g., ABCDEFGHIJKLMNOPQRSTUVWXYZ
PMJSQOLEYTVUAXIKCGBWDRNHZF
• This would also give 26! possibilities

5
Pigpen Cipher
• Pigpen cipher is a variation on letter substitution
• Alphabets are arranged as follows:

A B C J K L

D E F
M N O

G H I
P Q R

6
Pigpen Cipher diagram (cont’d)
S W

T U X Y

V Z

A C G W

7
Pigpen Cipher
• Alphabets will be represented by the corresponding
diagram
• E.g., WAG would be

• This is a weak cipher

8
ADFGVX Cipher
• This is a variation on A D F G V X
substitution cipher and is
a strong cipher A 8 p 3 d 1 n
D l t 4 o a h
F 7 k b c 5 z
G j u 6 w g m
V x s v i r 2
X 9 e y 0 f q

9
ADFGVX Cipher
• Rules:
• Remove spaces and punctuation marks from message
• For each letter or number substitute the letter pair from
the column and row heading
• Next, use a transposition operation on the pair of letters
using a key word (which the receiver knows)
• Rearrange the columns of the new arrangement in
alphabetical order
• Finally, arrange the letters from consecutive columns

10
ADFGVX Cipher
• E.g., Message = SEE ME IN MALL
• SEEMEINMALL
• VDXDXDGXXDVGAXGXDVDADA
• Use keyword of INFOSEC
• Arrange the stage 1 ciphertext characters in a fresh grid
with keyword as the column heading
• Ciphertext is written in column order from left to right

11
ADFGVX Cipher
I N F O S E C

V D X D X D G

X X D V G A X

G X D V D A V

12
ADFGVX Cipher
C E F I N O S

G D X V D D X

X A D X X V G

V A D G X V D

13
ADFGVX Cipher
• Ciphertext is:
GXVDAAXDDVXGDXXDVVXGD
• Recipient reverses the process using the same
keyword and gets the plaintext
• Reason for this cipher using the name ADFGVX is
that in Morse code these characters all have
dissimilar patterns of dots and dashes

14
Polyalphabetic Cipher
• In monoalphabetic cipher the problem was that
each character was substituted by a single
character
• Cryptanalysts are helped by the fact that they have
to see what character would correspond in
plaintext for a given ciphertext character
• Polyalphabetic cipher’s goal is to make this process
difficult

15
Polyalphabetic Cipher
• In polyalphabetic cipher, each plaintext character
may be replaced by more than one character
• Since there are only 26 alphabets this process will
require using a different representation than the
alphabets
• Alphabets ‘A’ through ‘Z’ are replaced by 00, 01, 02,
…, 25
• We need two digits in this representation since we
need to know how to reverse the process at the
decryption side

16
Polyalphabetic Cipher
• The most common method used is Vigenère cipher
• Vigenère cipher starts with a 26 x 26 matrix of
alphabets in sequence. First row starts with ‘A’,
second row starts with ‘B’, etc.
• Like the ADFGVX cipher, this cipher also requires a
keyword that the sender and receiver know ahead
of time
• Each character of the message is combined with
the characters of the keyword to find the
ciphertext character

17
Vigenère Cipher Table
ABCDEFGHIJKLMNOPQRSTUVWXYZ

A ABCDEFGHIJKLMNOPQRSTUVWXYZ
B BABCDEFGHIJKLMNOPQRSTUVWXY
C CDEFGHIJKLMNOPQRSTUVWXYZAB
D DEFGHIJKLMNOPQRSTUVWXYZABC
E EFGHIJKLMNOPQRSTUVWXYZABCD
F FGHIJKLMNOPQRSTUVWXYZABCDE
G GHIJKLMNOPQRSTUVWXYZABCDEF
H HIJKLMNOPQRSTUVWXYZABCDEFG
I IJKLMNOPQRSTUVWXYZABCDEFGH
J JKLMNOPQRSTUVWXYZABCDEFGHI
K KLMNOPQRSTUVWXYZABCDEFGHIJ
L LMNOPQRSTUVWXYZABCDEFGHIJK
MMNOPQRSTUVWXYZABCDEFGHIJKL

18
Vigenère Cipher Table (cont’d)
ABCDEFGHIJKLMNOPQRSTUVWXYZ

N NOPQRSTUVWXYZABCDEFGHIJKLM
O OPQRSTUVWXYZABCDEFGHIJKLMN
P PQRSTUVWXYZABCDEFGHIJKLMNO
Q QRSTUVWXYZABCDEFGHIJKLMNOP
R RSTUVWXYZABCDEFGHIJKLMNOPQ
S STUVWXYZABCDEFGHIJKLMNOPQR
T TUVWXYZABCDEFGHIJKLMNOPQRS
U UVWXYZABCDEFGHIJKLMNOPQRST
V VWXYZABCDEFGHIJKLMNOPQRSTU
W WXYZABCDEFGHIJKLMNOPQRSTUV
X XYZABCDEFGHIJKLMNOPQRSTUVW
Y YZABCDEFGHIJKLMNOPQRSTUVWX
Z ZABCDEFGHIJKLMNOPQRSTUVWXY

19
Polyalphabetic Cipher
• E.g., Message = SEE ME IN MALL
• Take keyword as INFOSEC
• Vigenère cipher works as follows:
SEEME I NMALL
I NFOSEC I NFO
-------------------------------------
A RJ AWMPUNQZ

20
Polyalphabetic Cipher
• To decrypt, the receiver places the keyword
characters below each ciphertext character
• Using the table, choose the row corresponding to
the keyword character and look for the ciphertext
character in that row
• Plaintext character is then at the top of that
column

21
Polyalphabetic Cipher
• Decryption of ciphertext:
A RJ AWMPUNQZ
I NFO S EC I NFO
-------------------------------------
S E EMEIN MALL
• Best feature is that same plaintext character is
substituted by different ciphertext characters (i.e.,
polyalphabetic)

22
Vigenère Cipher
• Easiest way to handle Vigenère cipher is to use
arithmetic modulo 26
• This approach dispenses with the need for the table
• Keyword is converted to numbers and
corresponding numbers in message and keyword
are added modulo 26

23
Beale Cipher
• Also known as book cipher
• Keyword is taken as the first few words of a book
that is agreed upon by sender and receiver
• Everything else works like the Vigenère cipher

24
Polyalphabetic cipher
• Vigenère cipher uses the fact that the keyword
character helps to get different ciphertext
characters from the table
• Instead of the Vigenère table, one could develop a
new table in which each character is represented as
an integer and the ciphertext could use multiple
digits for substitution depending on the frequency
analysis of the letter
• E.g., Q gets only one substitution value where as E
gets 12 different substitution values, and so on

25
Multiple Letter Cipher
• Playfair cipher is a multiple letter cipher
• Each plaintext letter is replaced by a digram in this
cipher
• Number of digrams is 26 x 26 = 676
• User chooses a keyword and puts it in the cells of a
5 x 5 matrix. I and J stay in one cell. Duplicate
letters appear only once.
• Alphabets that are not in the keyword are arranged
in the remaining cells from left to right in
successive rows in ascending order

26
Playfair Cipher
• Keyword “Infosec”
I/J N F O S

E C A B D

G H K L M

P Q R T U

V W X Y Z

27
Playfair Cipher
• Rules:
• Group plaintext letters two at a time
• Separate repeating letters with an x
• Take a pair of letters from plaintext
• Plaintext letters in the same row are replaced by letters
to the right (cyclic manner)
• Plaintext letters in the same column are replaced by
letters below (cyclic manner)
• Plaintext letters in different row and column are
replaced by the letter in the row corresponding to the
column of the other letter and vice versa

28
Playfair Cipher
• E.g., Plaintext: “CRYPTO IS TOO EASY”
• Keyword is “INFOSEC”
• Grouped text: CR YP TO IS TO XO EA SY
• Ciphertext: AQ VT YB NI YB YF CB OZ
• To decrypt, the receiver reconstructs the 5 x 5
matrix using the keyword and then uses the same
rules as for encryption

29
Vernam Cipher
• U.S. Army Major Joseph Mauborgne and AT&T’s
Gilbert Vernam developed a cipher in 1917
• Uses a one time arrangement of a key string that is
as long as the plaintext
• Plaintexts are assumed to be short
• Also known as One-Time Pad cipher
• Key is used only once but characters in key may not
be distinct

30
Vernam Cipher
• E.g., Plaintext: HELLO
Key: KTBXZ
--------------
Ciphertext : RXMIN (using addition mod 26)
Key: KTBXZ
--------------
Plaintext: HELLO (using subtraction mod 26)

31
Transposition Cipher
• Also known as a permutation cipher
• Permutation is an arrangement of the original
order of letters or numbers
• E.g., a = 1 2 3
312
• “a” is a permutation of 1, 2, 3 such that
1 3 2 1 3 2

32
Transposition Cipher
• a2 = 1 2 3 a3 = 1 2 3
231 123

• a3 is really identity as it does not change the order


of the elements
• “a” is said to have order 3, written |a| = 3
• “a” is an odd permutation as its order is an odd
number

33
Transposition Cipher
• In Transposition cipher position of character
changes but not its value
• This is different from substitution cipher
• Assign values 0, 1, 2, …, 25 to the alphabets
• Choose an integer n as the size of a block
• Split the message into blocks of size n

34
Transposition Cipher
• p = (p(1), p(2), …, p(n)) be a permutation of (1, 2, …,
n)
• Message is encrypted using the values of p(1), p(2),
…, p(n)
• E.g. Let n = 4
• Let p = 1 2 3 4
2413

35
Transposition Cipher
• message = proceed meeting as agreed
• Since n = 4, we split the message as follows: proc
eedm eeti ngas agre ed
• We pad the last block with two spaces
• Encrypt using the permutation order
• Last block becomes d _ e _ where _ denotes a blank
space
• Delete the blank spaces in encrypted text

36
Transposition Cipher
• Ciphertext using the permutation is:
rcpoemedeietgsnagearde
• To decrypt, the receiver simply takes the inverse of
the permutation
• In the last block of ciphertext we have de
• The two missing characters corresponding to 3-1
and 4-1 are thus blanks in plaintext

37

You might also like