|
|
|
|
|
|
|
|
|
key = "C X Y B W P R V Q J Z M N T K E L D F G H I O U S" |
|
|
|
|
|
def encrypt(message,dic): |
|
ciphertext = "" |
|
for char in message: |
|
if char.isalpha(): |
|
|
|
if char.isupper(): |
|
|
|
encrypted = key[ord(char) - ord("A")].lower() |
|
else: |
|
|
|
encrypted = key[ord(char) - ord("a")].upper() |
|
ciphertext += encrypted |
|
return ciphertext |
|
|
|
def decrypt(message,dic): |
|
plaintext = "" |
|
for char in message: |
|
if char.isalpha(): |
|
|
|
if char.isupper(): |
|
|
|
decrypted = key[25 - key.index(char.lower())].upper() |
|
else: |
|
|
|
decrypted = key[25 - key.index(char)].lower() |
|
plaintext += decrypted |
|
return plaintext |
|
|
|
|
|
|