Skip to content
Substitution Cipher

Substitution Cipher

Introduction

Each character in the plaintext is substituted by another character in the ciphertext.

Types of Substitution Cipher

Simple Substitution Cipher

This is also known as Monoalphabetic Cipher.

Each character of the plaintext is mapped to a corresponding character of ciphertext.

Homophonic Substitution Cipher

A single character of plaintext can be mapped to one or more characters of ciphertext.

Polygram / Polygraphic Substitution Cipher

Blocks of characters are encrypted in groups.

Polyalphabetic Substitution Cipher

This is made up of multiple simple substitution ciphers.

Shift Cipher (Caesar Cipher)

The 26 letters are mapped from 0 to 25.

  • The key space is K={0,1,,24,25}K = \{0,1,\dots,24,25\}.
  • GenGen chooses kKk \in K uniformly.
  • Enck(m1,m2,,mi)Enc_k(m_1,m_2,\dots,m_i) outputs c1,c2,,cic_1,c_2,\dots,c_i, where ci(mi+k)mod26 c_i \coloneqq (m_i + k) \mod 26
  • Deck(c1,c2,,ci)Dec_k(c_1,c_2,\dots,c_i) outputs m1,m2,,mim_1,m_2,\dots,m_i, where mi(cik)mod26 m_i \coloneqq (c_i - k) \mod 26

Vigenere Cipher

The 26 letters are mapped from 0 to 25.

The secret key kk is a string, and ll denotes the length of kk.

The ciphertext is generated by:

ci=(mi+k(imodl))mod26 c_i = (m_i + k_{(i \mod l)}) \mod 26

A Vigenere Square can be used to encrypt and decrypt conveniently.

Vigenere Square

Where cic_i is the intersection character of mim_i and k(imodl)k_{(i \mod l)}

Transposition Ciphers

The plaintext remains the same, and oly the order of characters is shuffled around.

Rail Fence Cipher

The secret key is an integer, called rails.

Suppose to encrypt the message “HELLO_WORLD”, if k=2k = 2, then

H L O W R D
 E L _ O L

The ciphertext is “HLOWRDEL_OL”.

If k=3k = 3, then

H   O   R
 E L _ O L
  L   W   D

The ciphertext is “HOREL_OLLWD”.

Simple Columnar Transposition

The plaintext is written horizontally into a table, and the ciphertext is read off vertically.

The secret key is a string.

Suppose the key is “SECRET”, and the plaintext is “HELLO WORLD”, the table will be:

S (5)E (2)C (1)R (4)E (3)T (6)
HELLOW
ORLD

Then read vertically according to the order of letters in the secret key. The ciphertext will be “LLEROLDHOW”.

Last updated on