Skip to content

create monoalphabetic cipher #3449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 17, 2020
Prev Previous commit
Next Next commit
update file
  • Loading branch information
radadiyamohit81 authored Oct 17, 2020
commit b01883e1508c77c69f8ebe5e6d095c71b4c56185
11 changes: 4 additions & 7 deletions ciphers/mono_alphabetic_ciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

def translate_message(key, message, mode):
"""
>>> translate_message(
"QWERTYUIOPASDFGHJKLZXCVBNM",
"Hello World!",
"encrypt")
>>> translate_message("QWERTYUIOPASDFGHJKLZXCVBNM","Hello World","encrypt")
'Pcssi Bidsm'
"""
charsA = LETTERS if mode == "decrypt" else key
Expand All @@ -29,22 +26,22 @@ def translate_message(key, message, mode):

def encrypt_message(key: str, message: str) -> str:
"""
>>> encrypt_message("QWERTYUIOPASDFGHJKLZXCVBNM", "Hello World!")
>>> encrypt_message("QWERTYUIOPASDFGHJKLZXCVBNM", "Hello World")
'Pcssi Bidsm'
"""
return translate_message(key, message, "encrypt")


def decrypt_message(key: str, message: str) -> str:
"""
>>> decrypt_message("QWERTYUIOPASDFGHJKLZXCVBNM", "Hello World!")
>>> decrypt_message("QWERTYUIOPASDFGHJKLZXCVBNM", "Hello World")
'Itssg Vgksr'
"""
return translate_message(key, message, "decrypt")


def main():
myMessage = "Hello World!"
myMessage = "Hello World"
myKey = "QWERTYUIOPASDFGHJKLZXCVBNM"
myMode = "decrypt" # set to 'encrypt' or 'decrypt'

Expand Down