Introduction to Security · Cryptography and Network Security

Substitution Techniques

Watch lectures

Substitution Techniques

1. Substitution = Replace Letters, Keep Order

A substitution cipher replaces each plaintext symbol by another symbol; positions never move. General monoalphabetic map over 26 letters:

C=E(P),e.g. f:A→D,B→E,…C = E(P), \quad \text{e.g. } f: A \to D, B \to E, \dots

Key space 26!≈4×102626! \approx 4 \times 10^{26} — brute force impossible, yet every monoalphabetic cipher falls to statistics (Section 3). Contrast with transposition (Topic 8: move letters, keep identity).

2. The Classical Family

Cipher Rule (pp = 0–25) Key space Worked example
Caesar C=(p+k) mod 26C = (p + k) \bmod 26, decrypt (c−k)(c - k) 25 k=3k = 3: HELLO → KHOOR
Monoalphabetic Arbitrary permutation 26!≈28826! \approx 2^{88} Plain: ABC... / Cipher: DKV... — HELLO → "ULSSI"-style
Playfair (5×55 \times 5) Digraph rules (same row → right, same col → down, rectangle → swap) 25!25! MONARCHY square: HI → BM; decrypt reverses
Hill (m×mm \times m matrix KK) c=Kp mod 26\mathbf{c} = K\mathbf{p} \bmod 26; need det⁡K\det K invertible mod 26 (gcd⁡(det⁡,26)=1\gcd(\det,26) = 1) large K=[[3,3],[2,5]]K = [[3,3],[2,5]], "HI" =(7,8)= (7,8): c=(45,54) mod 26=(19,2)\mathbf{c} = (45, 54) \bmod 26 = (19, 2) → "TC"
Polyalphabetic (Vigenère) Ci=(pi+ki mod m) mod 26C_i = (p_i + k_{i \bmod m}) \bmod 26 26m26^m Key LEMON over ATTACKATDICK → LXFOPVEFRNHR
Autokey Key extends with plaintext itself — Key QUEEN + plaintext MEET... → cipher varies after key runs out
Vernam / One-Time Pad Ci=pi⊕kiC_i = p_i \oplus k_i, key random, length = message, never reused 2n2^n Only unconditionally secure cipher (Shannon)

Vigenère table check: A(0)+L(11) = L(11) ✓; T(19)+E(4) = X(23) ✓ — first two letters "AT" → "LX".

3. Breaking Monoalphabetic Ciphers — Frequency Analysis

English letter frequencies (≈\approx E 12.7%, T 9.1%, A 8.2%, O 7.5%, ...) transfer to ciphertext 1-to-1. Attack:

  1. Count ciphertext frequencies; guess most frequent = E, next = T/A/O.
  2. Use digrams (TH, HE most common) and trigrams (THE, AND) to confirm.
  3. Words: single-letter words are A/I; "TH-T" pattern is THAT.

Worked mini-break: C=C = "WKH TXHHQ RI WKH...": each letter is Caesar +3+3 (W→T? no — frequency says H most common → H = E means shift 3): subtract 3 → "THE QUEEN OF THE..." ✓. Monoalphabetic with 26!26! keys broke by hand — key size ≠ security.

Kasiski test (Vigenère): repeated blocks ("VTW" twice, distance 9) reveal key length m∣m \mid distances; then each of the mm Caesar columns falls to frequency analysis separately.

4. Why Polyalphabetic Matters and OTP Is Perfect

  • Monoalphabetic: one PP letter → one CC letter — statistics survive.
  • Polyalphabetic: one PP letter → many CC letters (flattens frequencies); key length mm is the security knob — m=1m = 1 is Caesar, m→m \to message length with random key is OTP.
  • OTP: C=P⊕KC = P \oplus K with ∣K∣=∣P∣|K| = |P|, KK truly random, used once → CC is uniform random regardless of PP → zero leakage (unconditional security). Two-time pad (KK reused) breaks instantly: C1⊕C2=P1⊕P2C_1 \oplus C_2 = P_1 \oplus P_2.

Exam Points

  • Formulas C=(p+k) mod 26C = (p+k) \bmod 26, Vigenère Ci=(pi+ki mod m)C_i = (p_i+k_{i \bmod m}), Hill c=Kp\mathbf{c} = K\mathbf{p} — 2-mark each.
  • Caesar "HELLO → KHOOR" and Vigenère "ATTACK/LEMON → LXFOPVEFRNHR" — standard numericals.
  • Frequency-analysis steps + Kasiski key-length trick — 5-mark theory core.
  • OTP three conditions (random, full-length, once) + two-time-pad break.
AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.

← All Cryptography and Network Security modules