Skip to content

Instantly share code, notes, and snippets.

@henkman
Created August 1, 2014 14:52
Show Gist options
  • Save henkman/8c4d984ce523059173a0 to your computer and use it in GitHub Desktop.
Save henkman/8c4d984ce523059173a0 to your computer and use it in GitHub Desktop.
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