Cipher Encoder/Decoder

Back to homepage

Project Overview

Write a program that encodes or decodes text using a cipher of your choice. This challenge started 2020 Nov 24 and ended 2020 Dec 08.

Submissions

Kat Crawford

cryptDict = { 
    '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':'--..', 
    '1':'.----', 
    '2':'..---', 
    '3':'...--', 
    '4':'....-', 
    '5':'.....', 
    '6':'-....', 
    '7':'--...', 
    '8':'---..', 
    '9':'----.', 
    '0':'-----', 
    ',':'--..--', 
    '.':'.-.-.-', 
    '?':'..--..', 
    '-':'-....-', 
    '(':'-.--.', 
    ')':'-.--.-',
    ' ':'/',
}

keyList = list(cryptDict.keys())
valueList = list(cryptDict.values())

decryptDict = {valueList[i]: keyList[i] for i in range(len(keyList))}

print("Decrypt (a) or Crypt (b)")


initialize = input()
a = input("Enter text: ")
b = a.upper()

def crypt():
    for letter in b:
        print(cryptDict[letter], end=" ")

def decrypt():
    for letter in a:
        print(decryptDict[letter], end="")


if initialize == "a":
    decrypt()

elif initialize == "b":
    crypt()

else:
    print("Your input was invalid.")

Landon Kahl

cipher = {"A":"T", "a":"T", "B":"D", "b":"D", "C":"L", "c":"L",
"D":"O", "d":"O", "E":"F", "e":"F", "F":"A", "f":"A", "G":"G", "g":"G", "H":"J",
"h":"J", "I":"K", "i":"K", "J":"R", "j":"R", "K":"I", "k":"I", "L":"C", "l":"C",
"M":"V", "m":"V", "N":"P", "n":"P", "O":"W", "o":"W", "P":"U", "p":"U", "Q":"X",
"q":"X", "R":"Y", "r":"Y", "S":"B", "s":"B", "T":"E", "t":"E", "U":"Z", "u":"Z",
"V":"Q", "v":"Q", "W":"S", "w":"S", "X":"N", "x":"N", "Y":"M", "y":"M", "Z":"H",
"z":"H"}
final_message = ""
first_message = input("Type Anything: ")
for letter in first_message:
    try:
        final_message += cipher[letter]
    except:
        final_message += letter
print(final_message)