Skip to content

Instantly share code, notes, and snippets.

@fadil703
Created February 25, 2019 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadil703/794b2f1bd6ad97458eeba92746c873e1 to your computer and use it in GitHub Desktop.
Save fadil703/794b2f1bd6ad97458eeba92746c873e1 to your computer and use it in GitHub Desktop.
from string import ascii_letters
cipher_letters = 'defghijklmnopqrstuvwxyzabcDEFGHIJKLMNOPQRSTUVWXYZABC'
trans = str.maketrans(ascii_letters, cipher_letters)
trans_rev = str.maketrans(cipher_letters, ascii_letters)
text_to_cipher = input('Text to cipher: ')
ciphered = text_to_cipher.translate(trans)
plaint = ciphered.translate(trans_rev)
print(f'Ciphered text: {ciphered}')
print(f'plain tex: {plaint}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment