# Myszkowski Transposition

- Description
- Algorithm
- Implementation

The encryption and decryption can be performed by hand, using a piece of paper and a simple matrix, into which the user enters the letters of the message.

Similarly to the Columnar Transposition, both encryption and decryption are performed by using a matrix. The number of columns of the matrix is determined by the secret key.

The Myszkowski Transposition requires the secret key that is usually a word (or just a sequence of letters). It should be converted into a sequence of numbers. The numbers are defined by an alphabetical order of the letters in the keyword. The letter which is first in the alphabet will be the number 1, the second letter in the alphabetical order will be 2, and so on.

Contrary to the Columnar Transposition, the keyword has to contain some recurrent letters. Identical letters should have the same numbers assigned (which is again, different from the Columnar Transposition).

For example, the keyword:

SWINDON

would produce the following sequence of numbers:

5623143

We can see, that we converted both letters N into two threes.

To encrypt a message, all the letters should be entered into the matrix, row by row, from left to right. The size of the matrix depends on the length of the message. The only known dimension is width, which is determined by the length of the secret keyword (which is the same as the length of the corresponding sequence of numbers), and known to both sides of the communication.

If, after entering the whole message, there are some empty cells in the bottom row of the matrix, one of two approaches can be taken:

- The cells may be left empty, and just ignored during all further operations.
- The sender may enter there some rare letters, and treat them as a part of the plaintext. After decryption, the receiver should be able to determine, that the letters have no sense, and that they should be ignored.

Next, the letters should be read off in a specific way, and write down to form the ciphertext. The order of reading the letters is determined by the sequence of numbers, produced from the keyword. They should be read column by column, from top to bottom, starting from the column, which position is the same as the position of the number 1 in the key sequence. The next column to read off is determined by the number 2 in the key sequence, and so on, until all the columns are read off.

If several columns have the same numbers assigned to them (and as we know, this is a requirement for this cipher), the letters from those columns should be read off together, row by row. This procedure is different from the one which is performed in the Columnar Transposition, which results in a different ciphertext being produced from both ciphers, even if all other parameters are the identical.

To make this step easier, and to allows the user quickly located each column, it is recommended to write the sequence numbers above the corresponding columns.

For example, let's encrypt a message A Midsummer Night's Dream, which is a comedy written by Shakespeare (this is the same message we encrypted with the Columnar Transposition). We will use the secret key mentioned above. The number sequence derived from this keyword is 5623143, so the matrix created for the encryption will have seven columns.

After removing all non-letter characters, and changing the letters to upper case, the message should be entered into the table:

5 | 6 | 2 | 3 | 1 | 4 | 3 |

A | M | I | D | S | U | M |

M | E | R | N | I | G | H |

T | S | D | R | E | A | M |

There are numbers derived from the keyword written above the message. These numbers determine the order, in which the columns should be read (top to bottom), and appended to the produced ciphertext. In our example, the first column will be SIE, and the second will be IRD. Then, there are two columns which have threes assigned: DNR and MHM. The letters from them should be read off row by row, starting from the top. All the remaining columns should be dealt with in a usual way. The produced ciphertext is:

SIE IRD DMNHRM UGA AMT MES

Finally, after removing the spaces, which were added to indicate separate columns, we receive the encrypted message:

SIEIRDDMNHRMUGAAMTMES

To decrypt a received ciphertext, the receiver has to perform the following steps:

- Knowing the secret keyword, and the length of the received message, the table of the same size, as the one used for encryption, should be created.
- The ciphertext should be entered into columns, from the leftmost columns to the rightmost column, from top to bottom. The columns with the same numbers should be filled together, row by row.
- The columns should be rearranged, and put into the order defined by the keyword.
- The decrypted message should be read out, row by row, starting from the top row, and from left to right.

## Security of the Myszkowski Transposition

The Myszkowski Transposition provides a quite comparable level of protection as the Columnar Transposition.

To break the ciphertext, an attacker should act in a similar way. That is, he should create the tables of different sizes, enter the encrypted message down into the columns, and for each table look for anagrams appearing in rows.