Skip to content

Instantly share code, notes, and snippets.

@paced
Last active November 13, 2017 23:17
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 paced/2ae4873b842121e32f4118c95e7e4f1b to your computer and use it in GitHub Desktop.
Save paced/2ae4873b842121e32f4118c95e7e4f1b to your computer and use it in GitHub Desktop.
Very simple Python code for breaking substitution ciphers.
from string import maketrans
def decrypt(in, out, test):
"""
Given a plaintext input, encrypted output, and an encrypted test string, return a
decrypted test string. This will only work for a substitution-style cipher.
"""
cipher = maketrans(out, in)
return test.translate(cipher)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment