Scytale cipher

The following text was encrypted using a simple columnar transposition cipher:

sattvnyanohedtyslerehtwiusvihefneenereiarg

Decrypt the text. What is the correct answer to the question?

(If you still do not know, you can google the phrase.)

The scytale was an encryption tool used to perform a transposition cipher. It consisted only of a rod with a certain diameter around which a leather strap was wound. A message was written on the leather strap, so that only one character was placed in each 'column'. By unwinding the leather band rows and columns were swapped, so that the message now appears as a meaningless string.


Image credit: CC BY-SA 3.0 , https://commons.wikimedia.org/w/index.php?curid=1698345


The answer is 42.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Markus Michelmann
May 21, 2018

The ciphertext has a length l = n m l = n \cdot m and can be entered in a matrix with width m m and height n n . Decryption is done by transposing the matrix (swapping rows and columns): plainText [ i m + j ] = cipherText [ j n + i ] \text{plainText}[i * m + j] = \text{cipherText}[j * n + i] where i = 0 , , n 1 i = 0, \dots , n-1 , j = 0 , , m 1 j = 0, \dots , m-1 . By trial and error we find that n = 7 n = 7 and m = 6 m = 6 are the right dimensions for the matrix. The decrypted message is then

say the answer to life the universe and everything

which is obviously 42. 42 also happens to be the length of the string. The fact 6 7 = 42 6 \cdot 7 = 42 was used for the transposition encryption.

Sample code for decryption:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cipherText = "sattvnyanohedtyslerehtwiusvihefneenereiarg"

def scytale(text, n):
    result = ""
    for i in range(n):
        for j in range(int(len(text)/n)):
            result = result + text[n*j + i]
    return result

plainText = scytale(cipherText,7)
print(plainText)
print(len(plainText))

Julien Marcuse
Jun 7, 2018

public class Main {

    public static void main(String []args){
        String value = "sattvnyanohedtyslerehtwiusvihefneenereiarg";
        String combine = "";
        int shift = 7;
        for (int s = 0; s < shift; s++) {
            for (int i = s; i < value.length(); i += shift) {
                combine += value.charAt(i);
            }
        }
        System.out.println(combine);
    }
}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...