Welcome to the Ceasor Cipher Game!
This is a fun, interactive Python project that lets you learn about and play with the classic Caesar Cipher encryption technique. Encrypt your secret messages, challenge your friends to decode them, and explore the basics of cryptographyβall in one game! πβ¨
- Encrypt & Decrypt: Encode your messages with a shift of your choice and decode messages from friends.
- User-Friendly Interface: Simple, clear prompts and outputs for beginners and enthusiasts alike.
- Custom Shift Amount: Choose how secret you want your message to be.
- Replayable: Play as many rounds as you like!
git clone https://github.com/Lakshitpythondevloper/Ceasor-Cipher-Game.git
cd Ceasor-Cipher-GameMake sure you have Python 3.x installed.
To start the game, run:
python ceasor_cipher_game.py- Select an option: Encrypt or decrypt a message.
- Enter your message: Type in the text you want to encode or decode.
- Set the shift: Pick the number of positions each letter will be moved in the alphabet.
- See the result: Your encrypted or decrypted message appears!
The Caesar Cipher is one of the oldest known encryption techniques. It works by shifting each letter in your message by a set number of places in the alphabet.
For example, with a shift of 3:
Aβ‘οΈD,Bβ‘οΈE,Cβ‘οΈF, β¦ and so on.
Ceasor-Cipher-Game/
β
βββ ceasor_cipher_game.py # Main game logic
βββ README.md # This beautiful file!
βββ LICENSE # License info
print(r'''
________ _______ ________ ________ _______ _________ ________ ________ ________ _______
|\ ____\|\ ___ \ |\ ____\|\ __ \|\ ___ \|\___ ___\ |\ ____\|\ __ \|\ ___ \|\ ___ \
\ \ \___|\ \ __/|\ \ \___|\ \ \|\ \ \ __/\|___ \ \_| \ \ \___|\ \ \|\ \ \ \_|\ \ \ __/|
\ \_____ \ \ \_|/_\ \ \ \ \ _ _\ \ \_|/__ \ \ \ \ \ \ \ \ \\\ \ \ \ \\ \ \ \_|/__
\|____|\ \ \ \_|\ \ \ \____\ \ \\ \\ \ \_|\ \ \ \ \ \ \ \____\ \ \\\ \ \ \_\\ \ \ \_|\ \
____\_\ \ \_______\ \_______\ \__\\ _\\ \_______\ \ \__\ \ \_______\ \_______\ \_______\ \_______\
|\_________\|_______|\|_______|\|__|\|__|\|_______| \|__| \|_______|\|_______|\|_______|\|_______|
\|_________|
''')- Uses raw string (
r'') to display an ASCII art title banner - Creates an attractive visual interface for users
alphabet = ['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']- Defines a list containing all lowercase letters of the English alphabet
- Used as the reference for shifting letters during encryption/decryption
def encrypt(originaltext, shift_amount):
Ceaser = ""
for letters in originaltext:
shifted_postion = alphabet.index(letters) + shift_amount
shifted_postion %= len(alphabet)
Ceaser += alphabet[shifted_postion]
print(f"Here is a encoded text : {Ceaser}")- Takes two parameters: the original text and the shift amount
- For each letter:
- Finds its position in the alphabet
- Adds the shift amount
- Uses modulo to handle wrapping around the alphabet
- Builds the encrypted string
- Prints the final encrypted text
def decode(originaltext, shift_amount):
Ceaser = ""
for letters in originaltext:
shifted_postion = alphabet.index(letters) - shift_amount
Ceaser += alphabet[shifted_postion]
print(f"Here is a decode text : {Ceaser}")- Takes two parameters: the encoded text and the shift amount
- Reverses the encryption process by:
- Finding each letter's position
- Subtracting the shift amount
- Building the decrypted string
- Prints the decrypted text
restart = True
while restart:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt: ").lower()
text = input("Type your message: ").lower()
shift = int(input("Type shift number: "))- Creates an interactive loop for multiple operations
- Prompts user for:
- Operation type (encode/decode)
- Message to process
- Shift value
if direction == "encode":
encrypt(text, shift)
restart_request = input("Do you want to restart the game Type Y or N: ")
elif direction == "decode":
decode(text, shift)
restart_request = input("Do you want to restart the game Type Y or N: ").capitalize()
else:
print("Invalid input, please try again.")- Handles user input validation
- Calls appropriate function based on user choice
- Asks if user wants to continue
if restart_request == 'N':
restart = False
else:
restart = True
print("Thank you for playing the game")- Controls program flow based on user's restart choice
- Provides feedback to user
- Run the program
- Choose 'encode' or 'decode'
- Enter your message (lowercase letters only)
- Enter the shift number
- View the result
- Choose to continue or exit
Type 'encode' to encrypt, type 'decode' to decrypt: encode
Type your message: hello
Type shift number: 3
Here is a encoded text: khoor
- Only supports lowercase letters
- No support for:
- Spaces
- Numbers
- Special characters
- Uppercase letters
Contributions are welcome!
If you have suggestions or improvements, feel free to fork this repository and submit a pull request.
This project is licensed under the MIT License.
Developed by Lakshitpythondevloper
If you enjoy this project, please βοΈ the repo to show your support!
βCryptography is the ultimate puzzle!β π§©