An interactive Python implementation of the classic Caesar Cipher, letting you encrypt and decrypt messages with any shift value.
The Caesar Cipher is one of the oldest known encryption techniques: each letter in a message is shifted a fixed number of positions down the alphabet. This notebook implements both encryption and decryption with a simple interactive loop — enter a message and a shift value, and get the transformed text back.
Example from the notebook:
Would you like to (e)ncrypt or (d)ecrypt a message? (e/d): d
Enter your message: jgnnq aqw
Enter the shift value: 2
Decrypted message: hello you
caesar_cipher_encrypt(plaintext, shift)— shifts each alphabetic character forward byshiftpositions using modular arithmetic (% 26), preserving casecaesar_cipher_decrypt(ciphertext, shift)— reverses the shift to recover the original message- Uppercase and lowercase letters are handled independently, so case is preserved
- Any shift value works — shifts wrap around the alphabet thanks to the modulo operation
- An interactive
main()loop lets you encrypt/decrypt repeatedly until you choose to quit
- Python 3 — pure standard library, no external dependencies
- Jupyter Notebook (developed in Google Colab)
-
Clone the repository:
git clone https://github.com/techieshreya/Encrypt-and-Decrypt-text-using-the-Caesar-Cipher-algorithm.git
-
Open
encrypt_decrypt.ipynbin Jupyter Notebook or Google Colab. -
Run the cell and follow the prompts to encrypt or decrypt your message.