Last active
November 13, 2017 23:17
-
-
Save paced/2ae4873b842121e32f4118c95e7e4f1b to your computer and use it in GitHub Desktop.
Very simple Python code for breaking substitution ciphers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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