This is a simple Python implementation of the Caesar Cipher encryption and decryption technique. The Caesar Cipher works by shifting letters in the alphabet by a fixed amount. It can be used to encode or decode a message by specifying the direction (encrypt or decrypt).
- The user is prompted to choose whether they want to
encode(encrypt) ordecode(decrypt) a message. - The user enters their message, which is converted to lowercase for consistency.
- The user specifies a shift value, determining how many positions each letter moves in the alphabet.
- The program then processes the message:
- If encoding, each letter is shifted forward.
- If decoding, each letter is shifted backward.
- Non-alphabet characters (such as numbers, spaces, and punctuation) remain unchanged.
- The encrypted or decrypted result is displayed.
- The user can choose to run again or exit the program.
Type 'encode' to encrypt, type 'decode' to decrypt:
encode
Type your message:
hello
Type the shift number:
3
Here is the encoded result: khoor
Type 'encode' to encrypt, type 'decode' to decrypt:
decode
Type your message:
khoor
Type the shift number:
3
Here is the decoded result: hello
β Simple and beginner-friendly Python implementation. β Works with both encryption and decryption. β Handles non-alphabet characters properly. β Allows users to continue or exit as needed.
- Copy the Python code into a file (e.g.,
caesar_cipher.py). - Run the script in a Python environment:
python caesar_cipher.py
- Follow the prompts to encrypt or decrypt messages.
We hope you enjoy using this simple Caesar Cipher program! Have fun encrypting and decrypting messages! π