Another approach to cryptography is transposition cipher.
transposition cipher
A transposition cipher is one in which the order of characters is changed to obscure the message.
An early version of a transposition cipher was a Scytale[1], in which paper was wrapped around a stick and the message was written. Once unwrapped, the message would be unreadable until the message was wrapped around a same-sized stick again.
One modern transposition cipher is done by writing the message in rows, then forming the encrypted message from the text in the columns. Let’s try an example.
Encrypt the message “Meet at First and Pine at midnight” using rows [latex]8[/latex] characters long.
We write the message in rows of 8 characters each. Nonsense characters are added to the end to complete the last row. [latex]MEETATFI[/latex] [latex]RSTANDPI[/latex] [latex]NEATMIDN[/latex] [latex]IGHTPXNR[/latex]. We could then encode the message by recording down the columns.
The first column, reading down, would be [latex]MRNI[/latex].
Altogether, the encoded message would be [latex]MRNI\: ESEG\: ETAH\: TATT\: ANMP\: TDIX\: FPDN\: IINR[/latex]. The spaces would be removed or repositioned to hide the size of the table used, since that is the encryption key in this message.
More complex versions of this rows-and-column based transposition cipher can be created by specifying an order in which the columns should be recorded. For example, the method could specify that after writing the message out in rows that you should record the third column, then the fourth, then the first, then the fifth, then the second. This adds additional complexity that would make it harder to make a brute-force attack.
To make the encryption key easier to remember, a word could be used. For example, if the key word was “[latex]MONEY[/latex]”, it would specify that rows should have [latex]5[/latex] characters each. The order of the letters in the alphabet would dictate which order to read the columns in. Since [latex]E[/latex], the [latex]4[/latex]th letter in the word, is the earliest letter in the alphabet from the word [latex]MONEY[/latex], the [latex]4[/latex]th column would be used first, followed by the [latex]1[/latex]st column ([latex]M[/latex]), the [latex]3[/latex]rd column ([latex]N[/latex]), the [latex]2[/latex]nd column ([latex]O[/latex]), and the [latex]5[/latex]th column ([latex]Y[/latex]).
Encrypt the message [latex]BUY\: SOME\: MILK\: AND\: EGGS[/latex] using a transposition cipher with key word [latex]MONEY[/latex].
Writing out the message in rows of [latex]5[/latex] characters: [latex]BUYSO[/latex][latex]MEMIL[/latex][latex]KANDE[/latex][latex]GGSPK[/latex]. We now record the columns in order [latex]4\: 1\: 3\: 2\: 5[/latex] : [latex]SIDP\: BMKG\: YMNS\: UEAG\: OLEK[/latex]. As before, we’d then remove or reposition the spaces to conceal evidence of the encryption key.
To decrypt a keyword-based transposition cipher, we’d reverse the process.
Decrypt the message [latex]RHA\: VTN\: USR\: EDE\: AIE\: RIK\: ATS\: OQR[/latex] using a row-and-column transposition cipher with keyword [latex]PRIZED[/latex].
The keyword [latex]PRIZED[/latex] tells us to use rows with [latex]6[/latex] characters. Since [latex]D[/latex] comes first in the alphabet, we start with [latex]6[/latex]th column. Since [latex]E[/latex] is next in the alphabet, we’d follow with the [latex]5[/latex]th column. Continuing, the word [latex]PRIZED[/latex] tells us the message was recorded with the columns in order [latex]4\: 5\: 3\: 6\: 2\: 1[/latex].For the decryption, we set up a table with [latex]6[/latex] characters in each row. Since the beginning of the encrypted message came from the last column, we start writing the encrypted message down the last column.
Reading across the rows gives our decrypted message: [latex]AIRSTRIKEONHEADQUARTERSV[/latex]
Unfortunately, since the transposition cipher does not change the frequency of individual letters, it is still susceptible to frequency analysis, though the transposition does eliminate information from letter pairs.