Grille Cipher Attack
This is the fourth mission inspired by classical cryptography. In this mission we will attempt to break the Rotating Grille cipher. For more info on grille cipher check out missions Cipher Map and Rotating Grille Cipher - it's highly recommended that you've solved them before trying this one.
In cryptanalysis, Known Plaintext Attack , or KPA , is a mode of attack on a cipher where the analyst has access to both the ciphertext and to the corresponding plaintext; those can be used to derive the secret key and decipher all further messages encrypted with it. Some types of ciphers are very vulnerable to KPA: for instance, Caesar's cipher can be broken knowing just one pair of corresponding plaintext and ciphertext symbols; in other cases, finding the key requires a bit more work.
In this task we'll try to perform known plaintext attack on the rotating grille cipher. First, let's quickly go over the algorithm: the key to encryption is a square stencil with holes cut in it (in this mission we will use grille of size 8x8); the sender places the grille on a sheet and writes the first 16 letters of the message; then, turning the grille 90 degrees clockwise, the second 16 are written, and so on until the grid is filled. To decrypt a message, receiver arranges the cryptogram in an 8x8 square, places the grille on top of it and reads the letters in the holes, rotating the grille when necessary.
You are given two strings of text: a message and a corresponding cryptogram; both strings are 64 characters long. You need to find and return the grille used to encrypt the message. Like previous missions, the grille is a list of strings where "X" means hole, "." means no hole.
Important note: each input in this task is guaranteed to have a single solution.
Input: plaintext: string, cryptogram: string
Output: key: list of str size 8x8
Example:
find_grille('weareallfromxanthcubesaidquicklyjustvisitingphazewewontbeforlong', 'wejhewucuaeswtbrveeoisantsalilbifdteifrqunooigrmplxcakhonnlagtyz') == ['X...X...', '.X.....X', '..X...X.', '...X.X..', 'X.....X.', '...X...X', '..X.X...', '.X...X..']
Preconditions:
len(plaintext) == 64
len(cryptogram) == 64
len(key) == 8
all(len(line) == 8 for line in key)
all(all(cell == "X" or cell == "." for cell in line) for line in key)
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
checkio sync
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium
Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.
Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!
You are trying to join a pair programming session that has not started yet.
Please wait for the session creator to join.
It looks like the creator of the pair programming session closed the editor window.
It might happen accidentally, so that you can wait for reconnection.