๐ฏ Learning Objectives
- Understand what a Caesar Cipher is
- Explain encryption vs decryption
- Apply a shift cipher manually
- Write a basic Caesar Cipher algorithm
- Recognize strengths and weaknesses of simple encryption
๐ง What is a Caesar Cipher?
A Caesar Cipher is one of the oldest and simplest encryption techniques.
It is a type of substitution cipher.
Key Idea: Each letter is shifted a certain number of places down the alphabet.
A โ D
B โ E
C โ F
๐ History
- Named after Julius Caesar
- Used to send secret military messages
- Simple but important in the history of cryptography
๐ Key Vocabulary
Encryption
Turning readable text into secret code.
HELLO โ KHOOR
Decryption
Turning coded text back into readable text.
KHOOR โ HELLO
Plaintext
Original readable message.
Ciphertext
Encrypted (hidden) message.
Shift (Key)
Number of letters moved forward or backward.
๐ How the Caesar Cipher Works
Step 1 โ Choose a Shift Value
Shift = 3
Step 2 โ Shift the Alphabet
Alphabet:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shifted by 3:
DEFGHIJKLMNOPQRSTUVWXYZABC
Step 3 โ Replace Letters
Example: encrypt HELLO with shift 3
H โ K
E โ H
L โ O
L โ O
O โ R
Encrypted = KHOOR
๐ Wrap Around Rule
When shifting past Z, wrap back to A.
Z + 3 = C
Y + 3 = B
โ๏ธ Manual Practice Example
Encrypt DOG with shift 1:
D โ E
O โ P
G โ H
Encrypted = EPH
๐ป Algorithm (Simple Steps)
Encryption Algorithm
- Read message
- Choose shift value
- For each letter:
- Convert to alphabet position
- Add shift
- Wrap around if needed
- Convert back to letter
- Display encrypted text
๐จโ๐ป Java Logic Concept (High-Level)
This formula shifts uppercase letters and wraps using modulo:
char shifted = (char)((original - 'A' + shift) % 26 + 'A');
Why it works: Convert letter โ number, add shift, use % 26 to wrap, convert back.
๐ Decryption
Decryption shifts letters backwards.
decryptShift = 26 - shift
Or simply subtract shift instead of adding.
๐ Strengths
- Easy to understand
- Good introduction to cryptography
- Helps learn algorithms and modular arithmetic
โ ๏ธ Weaknesses
- Very easy to break
- Only 25 possible shifts
- Vulnerable to brute-force attacks
Important: Caesar Cipher is educational, not secure.
๐งช Real Cybersecurity Connection
Modern encryption uses:
- Complex math
- Large keys
- Algorithms like AES or RSA
Caesar Cipher is considered educational, not secure.
๐ Example Table
| Plain |
Shift |
Cipher |
| A | +3 | D |
| B | +3 | E |
| C | +3 | F |
๐งฉ Challenge Question
If Encrypted = ZRUOG and Shift = 3, what is the original message?