Caesar Cipher (Shift Cipher)
Summary: Each letter is shifted by a fixed number of
positions in the alphabet. The classic Caesar cipher uses a shift of 3,
but any shift value (1-25) can be used.
Example (Shift 3):
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Encryption:
- Plaintext: MEET AT DAWN
- Shift each letter by 3:
- M -> P, E -> H, E -> H, T -> W
- A -> D, T -> W
- D -> G, A -> D, W -> Z, N -> Q
- Ciphertext: PHHW DW GDZQ
Decryption: Shift back by 3 (or shift forward by
23).
Common shifts to try:
- ROT13 (shift 13): Self-reciprocal
- Traditional Caesar (shift 3)
- Brute force: Only 25 possible shifts
Additional Example (Shift 7):
- Plaintext: CODING IS FUN
- Shift alphabet by 7:
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
- Encryption:
- C->J, O->V, D->K, I->P, N->U, G->N
- I->P, S->Z
- F->M, U->B, N->U
- Ciphertext: JVKPUN PZ MBU
Brute Force Decryption Example: Given ciphertext:
KHOOR
Try all 26 shifts:
- Shift 0: KHOOR
- Shift 1: JGNNQ
- Shift 2: IFMMP
- Shift 3: HELLO <- Plaintext found!
- Shift 4: GDKKN
- ... (continue if needed)
ROT13 Example:
- Plaintext: HELLO WORLD
- Shift by 13:
- H->U, E->R, L->Y, L->Y, O->B
- W->J, O->B, R->E, L->Y, D->Q
- Ciphertext: URYYB JBEYQ
- Decrypt (shift by 13 again): HELLO WORLD
- Note: ROT13 is its own inverse (encoding = decoding)