Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
9 lines proc solution in Clear category for Rotating Grille Cipher by CDG.Axel
def grille_encrypt(plaintext: str, grille, rng=range(4)):
res, text = '', list(plaintext)
if sum(el.count('X') for el in grille) == 4:
while text:
part = [[''] * 4 for _ in rng]
for _ in rng:
part = [[text.pop(0) if grille[row][col] == 'X' else part[row][col] for col in rng] for row in rng]
grille = [*zip(*grille[::-1])]
res += ''.join(''.join(row) for row in part)
return res if len(plaintext) == len(res) else None
Dec. 16, 2021