21.1 Problem

Imagine that one day you received a mysterious e-mail to your inbox. At first you thought it was a spam, but it just looks like a complete gibberish. Upon more detailed inspection it turned out that the text got some regularity to it. So it might be a coded message. Just in case you saved it as trarfvf.txt (see the code snippets), since trarfvf was the title of the message.

Now, a simple method to code something is to use a shift cipher (see Figure 11).

Figure 11: Coding Discs. The outer disc contains the original alphabet. The inner disc contains the alphabet shifted by 2 characters

To that end you cut two discs out of paper with all the characters from the alphabet on them. You shift the inner disk by a certain number of fields (+2 in Figure 11). In order to encode a letter you move the red tick around to that character (in the outer circle). Next you read the encoded letter in the inner circle (as pointed by the tick). If a letter or a symbol from the original text is not in the disk you just retype it as it is.

This way, coding the phrase “JULIA :)” with shift +2 from Figure 11 would give us “LWNKC :)”

Anyway, here is a task for you. Use a frequency analysis to figure out the shift (rotation) used to code the message found in trarfvf.txt (~31 KiB).



CC BY-NC-SA 4.0 Bartlomiej Lukaszuk