Project 2 | Cyber Security Track | DecodeLabs Industrial Training Kit (Batch 2026)
A Python implementation of the classic Caesar (shift) cipher, built to demonstrate the fundamental IPO model of cryptographic systems:
INPUT (Plaintext) → PROCESS (Algorithm + Key) → OUTPUT (Ciphertext)
- 🔐 Encrypt any text using a customizable shift key
- 🔓 Decrypt ciphertext back to the original plaintext
- 🔤 Handles uppercase and lowercase letters independently
- 🔢 Leaves spaces, punctuation, and digits untouched
- ➕➖ Supports negative and out-of-range shift keys (via modulo wraparound)
- 🕵️ Bonus brute-force demo — shows all 25 possible shifts, illustrating why the Caesar cipher is a "lockbox, not a vault"
- ✅ Includes a small test suite validating round-trip correctness
The cipher shifts each letter's position in the alphabet by a fixed key n, wrapping around using modular arithmetic:
Encryption: E(x) = (x + n) % 26
Decryption: D(x) = (x - n) % 26
In Python, this is implemented using ord() (character → integer) and chr() (integer → character):
cipher_char = chr((ord(char) - 65 + shift) % 26 + 65)- Python 3.7+
python caesar_cipher.pyYou'll be prompted for:
- The text you want to encrypt
- A shift key (integer, e.g.
3)
The program then prints the encrypted text, decrypts it back, and confirms the round-trip was successful.
python test_caesar_cipher.pyEnter the text to encrypt: Attack at dawn!
Enter the shift key (e.g. 3): 3
--- Results ---
Plaintext : Attack at dawn!
Shift Key : 3
Encrypted : Dwwdfn dw gdzq!
Decrypted : Attack at dawn!
Round-trip Check: PASSED ✅
caesar-cipher-project/
├── caesar_cipher.py # Core encryption/decryption logic + CLI
├── test_caesar_cipher.py # Unit tests
└── README.md # This file
- Let the user pick a custom alphabet or symbol set
- Implement a Vigenère cipher (multi-character key) for stronger security
- Add frequency-analysis-based automatic decryption (no key needed)
The Caesar cipher isn't secure by modern standards (only 25 possible keys, and it preserves letter-frequency patterns — making it vulnerable to frequency analysis). But it's the foundational building block for understanding how modern encryption (like AES) evolved: confusion, diffusion, and mathematical transformation of data to protect confidentiality.
Built as part of the DecodeLabs Industrial Training Kit — Cyber Security, Project 2.