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:
Where:
is the encryption function.
is the plaintext value.
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 can range from 0 to 25.
Shift of 26 is effectively the same as a shift of 0.
Finding Shift Values:
Find for plaintext to ciphertext mappings (e.g., b -> h).
General approach:
Identify numeric values (for b & h).
Set up the equation: .
Solve for .
Ensure 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:
(concept of equivalent numbers).
Example of Congruences:
.
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:
.
Additional Notes:
Shifting left to obtain plaintext can be represented as 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.