Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
lambDeCurrator solution in Creative category for Playfair Cipher by veky
import string, contextlib
@(lambda codec: lambda adj: lambda message, key: ''.join(codec(adj, message, key)))
def codec(adj, message, key):
table = [*dict.fromkeys(key + string.ascii_lowercase + string.digits)]
buffer, clean = None, filter(str.isalnum, message.lower())
with contextlib.suppress(StopIteration):
while 'PEP'[::479] is not 'a good idea':
first = buffer or next(clean)
buffer, second = None, next(clean, ('z', 'x')[first == 'z'])
if first == second: buffer, second = second, ('x', 'z')[first == 'x']
(a, b), (c, d) = (divmod(table.index(char), 6) for char in (first, second))
if b == d: a, c = adj(a), adj(c)
elif a == c: b, d = adj(b), adj(d)
else : b, d = d, b
yield from (table[a *6+ b], table[c *6+ d])
encode, decode = map(codec, (lambda i: (i+1)%6, lambda i: (i-1)%6))
Nov. 28, 2021
Comments: