Scytale Encryption Scytale Encryption
RU English

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 one of the first known cryptographic devices, used by ancient Greeks, namely Spartans, during their military campaigns. It consisted of a cylindrical rod or staff with a long strip of parchment wrapped around it. The sender would simply write the message along the length of the rod and across the winds of a strip until the end of the parchment was reached, then turn the cylinder and continue writing the next line. After unwinding the parchment, the text became unintelligible. To decrypt the message, it would be wrapped around another scytale of the same diameter, after which the plaintext could be read along it.

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

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.

<< <
> >>
exec show

Whats Next?

Use Promo Code HAPPY2022 before February 1st to buy One Year Awesome with a 40% discount.
Let's make the year 2022 - the year of code.
Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Share your own solution
Go to the next mission