Example #1
0
def decrypt(cipher, polybius, keyword):
    untrans = untranspose(cipher, keyword)

    trans = {}
    for (val, key) in zip(polybius, itertools.product("ADFGX", repeat=2)):
        key = key[0] + key[1]
        trans[key] = val
    
    groups = [untrans[2*i:2*i+2] for i in range(len(untrans) / 2)]

    return "".join([trans[g] for g in groups])
def decrypt(cipher, key1, key2):
    return untranspose(untranspose(cipher, key2), key1)