This Python program demonstrates the Caesar Cipher algorithm for encrypting and decrypting messages. It's a simple substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet based on a user-defined key (shift value). This project is useful for learning basic cryptography, Python string handling, and user input. def encrypt(text, shift): result = for char in text: if char.isalpha(): shift_base = 65 if char.isupper() else 97 result += chr ((ord(char) - shift_base + shift) & 26 + shift_base) else: result += char return result def decrypt(text, shift) : return encrypt(text, -shift)
message = input ("Enter your message: ") shift = int(input ("Enter shift number: ")) encrypted = encrypt (message, shift) print("Encrypted message:", encrypted) decrypted = decrypt (encrypted, shift) print ("Decrypted message:", decrypted)