import base64

word_list = [
    "Apple",
    "Banana",
    "Cat",
    "Dog",
    "Elephant",
    "Fish",
    "Giraffe",
    "Horse",
    "Ice cream",
    "Jaguar",
    "Kangaroo",
    "Lion",
    "Monkey",
    "Noodle",
    "Orange",
    "Penguin",
    "Queen",
    "Rabbit",
    "Strawberry",
    "Tiger",
    "Umbrella",
    "Violin",
    "Watermelon",
    "Xylophone",
    "Yacht",
    "Zebra",
    "apple",
    "banana",
    "cat",
    "dog",
    "elephant",
    "fish",
    "giraffe",
    "horse",
    "ice cream",
    "jaguar",
    "kangaroo",
    "lion",
    "monkey",
    "noodle",
    "orange",
    "penguin",
    "queen",
    "rabbit",
    "strawberry",
    "tiger",
    "umbrella",
    "violin",
    "watermelon",
    "xylophone",
    "yacht",
    "zebra",
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "="
]

def encode(string):
    hideString = ""
    encoded_text = base64.b64encode(string.encode("utf-8"))
    encoded_text = encoded_text.decode("utf-8")
    for letter in encoded_text:
        for word in word_list:
            if word.startswith(letter):
                hideString = hideString + " " + word
                break
    return hideString

def decode(string):
    mainString = ""
    for i in string.split(" "):
        mainString = mainString + i[0]
    decoded_bytes = base64.b64decode(mainString)
    decoded_text = decoded_bytes.decode("utf-8", errors="ignore")
    return decoded_text

mode = int(input("1: Encode.\n2: Decode.\nselect mode: "))

if mode == 1:
    string = str(input("enter a text for encode: "))
    print(encode(string))
elif mode == 2:
    string = str(input("enter a text for decode: "))
    print(decode(string))
else:
    print("invalid mode.")