Created
August 1, 2014 14:52
-
-
Save henkman/8c4d984ce523059173a0 to your computer and use it in GitHub Desktop.
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 itertools import izip | |
import string | |
class Atbash: | |
def __construct(self): | |
self.atbash_abc = zip(string.ascii_lowercase, string.ascii_lowercase[::-1]) | |
self.atbash_abc_enc = {p[1]:p[0] for p in atbash_abc} | |
self.atbash_abc_dec = {p[0]:p[1] for p in atbash_abc} | |
def enc(self, s): | |
return "".join([atbash_abc_enc[c] if c in atbash_abc_enc else c for c in s.lower()]) | |
def dec(self, s): | |
return "".join([atbash_abc_dec[c] if c in atbash_abc_dec else c or " " for c in s.lower()]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment