Basic Encryption & Decryption using the Caesar Cipher, implemented in Python, C, C++, and as a browser-based web app.
Takes a plaintext message and a shift key, shifts each letter by that amount through the alphabet, and produces ciphertext. Decryption reverses the process using the same key (symmetric encryption).
Encrypt: E(x) = (x + n) % 26
Decrypt: D(x) = (x - n) % 26
Spaces, numbers, and punctuation are passed through unchanged.
caesar_cipher/
├── python/
│ └── caesar_cipher.py
├── cpp/
│ └── caesar_cipher.cpp
├── c/
│ └── caesar_cipher.c
└── web/
├── index.html
├── style.css
└── script.js
cd python
python caesar_cipher.pyRequires Python 3.x. No external libraries needed.
cd cpp
g++ caesar_cipher.cpp -o caesar_cipher
./caesar_ciphercd c
gcc caesar_cipher.c -o caesar_cipher
./caesar_cipherOpen web/index.html directly in any browser. No server required.
Enter the message: Hello World
Enter shift key (1-25): 3
Original : Hello World
Encrypted : Khoor Zruog
Decrypted : Hello World
- ASCII-based character manipulation using
ord()/chr()in Python, and direct casting in C/C++ - Modular arithmetic (
% 26) to wrap the alphabet circularly - Symmetric encryption — the same key is used to both encrypt and decrypt
- Edge case handling for spaces, punctuation, and mixed case
The Caesar cipher has only 25 possible keys, making it trivially breakable by brute force or frequency analysis. It is a learning tool, not a production-grade encryption method. Modern systems use AES-256 with keys of 2^256 possible values.