This is the second in a series of missions dedicated to classical cryptography. In this mission we will try to break the Scytale encryption.
Scytale is a transposition cipher. Unlike substitution ciphers, like Atbash or Caesar's cipher, here the letters of the plaintext remain unchanged, but their order is altered.
For example, suppose the message is "let's meet at eleven in the evening" and diameter of the rod allows to write 4 letters in a circle. The scytale with a message written on it would look like this:
After unwinding the strip the message becomes lteeeanvttaesetnmltieehneveg .
If an adversary intercepted a message, they wouldn't be able to read it unless they knew the key to encryption - in this case, the diameter of the cylinder (or, more specifically, number of letters that could be written in a circle around it). However, it could easily be found by trying several rods of different size. Another method (attributed to Aristotle) includes wrapping the parchment with encrypted message around a cone-shaped rod with varying diameter until a fragment of text becomes readable.
In this mission we'll try to break a scytale encryption. You have a cryptogram and a crib - a word that is expected to be in the decrypted message. You need to try all the possible keys until you get a plaintext that contains the crib. If after trying every key you either found no such plaintext, or found more than one possible keys - return None .
There is also one last piece of informaion: you know that the sender encrypts the messages using the shortest possible strip of parchment, so that there are no empty spaces on it. for example, the message "let's meet at eleven in the evening" , encrypted with key 5 , will look like this:
Note that the lines have different lengths. The cryptogram will be "leeteetvhntaeeistnenmeivgeln" .
Input: ciphertext: str, crib: str
Output: plaintext: str or None
scytale_decipher('aaaatctwtkdn', 'dawn') == 'attackatdawn' scytale_decipher('hdoeerlallrdow', 'world') == 'hellodearworld' scytale_decipher('totetshpmeecisendysescwticsriasraytlaegphet', 'sicret') == None #Crib is not in plaintext scytale_decipher('aaaatctwtkdn', 'at') == None #More than one possible decryptions
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
(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 --ff
checkio install-plugin --chromium