# Author Evan Arias
from Caesar_Cipher_art import logo
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']
print(logo)
def caesar(action, message, shift_amount):
memo = ""
if action == "encode":
for letter in message:
if letter in alphabet:
current_index = alphabet.index(letter)
new_index = (current_index + shift_amount) % len(alphabet)
memo += alphabet[new_index]
else:
memo += letter
print(f"The encoded text is {memo}")
elif action == "decode":
for letter in message:
if letter in alphabet:
current_index = alphabet.index(letter)
new_index = (current_index - shift_amount) % len(alphabet)
memo += alphabet[new_index]
else:
memo += letter
print(f"The decoded text is {memo}")
end = False
while not end:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n").lower()
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
caesar(direction, text, shift)
restart = input("Type 'yes\' if you want to go again. Otherwise type 'no\'\n").lower()
if restart == "no":
print("Goodbye")
end = True
logo = """
,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba,
a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8
8b ,adPPPPP88 8PP""""""" `"Y8ba, ,adPPPPP88 88
"8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88
`"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88
88 88
"" 88
88
,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba,
a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8
8b 88 88 d8 88 88 8PP""""""" 88
"8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88
`"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88
88
88
"""