Shift Cipher Study Notes

Introduction to Shift Ciphers

  • Basic Overview:

    • Working primarily with the lowercase alphabet from a to z.

    • Each letter corresponds to numbers from 0 to 25 (a=0, b=1, …, z=25).

    • If a different alphabet is used, the mapping will change accordingly.

Mapping Letters to Numbers

  • Mapping:

    • Letters a through z are mapped to numbers 0 to 25 as follows:

      • a -> 0, b -> 1, c -> 2, …, z -> 25.

  • Example of Mapping:

    • Letter 'a' (0) + shift 9 = 'j' (9).

    • Letter 'b' (1) + shift 9 = 'k' (10).

The Shift Cipher Concept

  • Definition:

    • A shift cipher creates two copies of the alphabet.

    • The second copy is shifted, wrapping-around any letters that fall off to the start of the alphabet.

  • Illustration:

    • In a shift cipher with a key of 9, 'r' (17) + 9 = 26 (equivalent to a when wrapped around).

    • Necessity to wrap around explained:

      • After adding the key, if the number exceeds 25, adjust by subtracting 26 to map to a letter in the range (0-25).

Mathematical Representation of Shift Ciphers

  • Establishing a Formula:

    • Define the formula for encryption:

      • Ek(x)=(x+k)extmod26E_k(x) = (x + k) ext{ mod } 26

    • Where:

      • EkE_k is the encryption function.

      • xx is the plaintext value.

      • kk is the shift key.

      • Output must be taken in mod 26 to ensure it's within the range of our letter mapping.

  • Shifting Examples:

    • For letter 's' (18):

      • Calculation: 18 + 9 = 27 → wrap to 1 (b).

Addressing Key Size and Shifts

  • Possible Key Values:

    • Key kk can range from 0 to 25.

    • Shift of 26 is effectively the same as a shift of 0.

  • Finding Shift Values:

    • Find kk for plaintext to ciphertext mappings (e.g., b -> h).

    • General approach:

      1. Identify numeric values (for b & h).

      2. Set up the equation: ciphertext=(plaintext+k)extmod26ciphertext = (plaintext + k) ext{ mod } 26.

      3. Solve for kk.

      4. Ensure kk is in the range 0-25 by adjusting with +26 if necessary.

Understanding Modular Arithmetic

  • Concept of Modulo:

    • Explains how numbers wrap around upon reaching their maximum in a defined range.

    • Example of congruences like but not limited to:

      • −14extmod26=12-14 ext{ mod } 26 = 12 (concept of equivalent numbers).

  • Example of Congruences:

    • 31extmod26=531 ext{ mod } 26 = 5.

    • Visually breaking down congruence into a simpler number realm formed by the modulus.

Generalizing the Shift Cipher Function

  • Final Encryption Formula:

    • General form for encryption in a Shift Cipher:

      • Ek(x)=(x+k)extmod26E_k(x) = (x + k) ext{ mod } 26.

  • Additional Notes:

    • Shifting left to obtain plaintext can be represented as Dk(x)=(x−k)extmod26D_k(x) = (x - k) ext{ mod } 26 for decryption.

Practical Application with Software

  • Using Ecrypt Application:

    • Software can be utilized to encrypt and decrypt messages according to user-defined keys and alphabets.

    • Ecrypt utilizes the affine cipher algorithm for encryption where shift is a special case.

Exercises and Examples Using Shift Cipher

  • Practice session to solidify understanding:

    • Encrypt a sample phrase using various keys and confirm through manual calculations.

Conclusion and Forward Look

  • Emphasis on understanding modular arithmetic and how it relates to ciphers.

  • Previews next sessions on congruences and further exploration in cryptography.