Tool to decrypt/encrypt with a transposition. A transposition cipher, also called columns permutation, is a technique to change the order of the letters in a text by placing it in a grid.
Transposition Cipher - dCode
Tag(s) : Transposition Cipher
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
A transposition cipher refers to any encryption method that rearranges the letters of a message without changing their actual values. The most common type is columnar transposition (described below), but many other variants exist:
A transposition cipher is an encryption method that rearranges the characters of a message into a different order/arrangement according to a transposition key/permutation key.
Transposition cipher is the generic term for any encryption method that rearranges the letters of the plaintext into a new order. In the literature, the term is also associated with a particular family of methods, notably columnar transposition (or rectangular transposition), which consists of writing the plaintext in a table/grid/rectangle and then reading its columns according to a permutation defined by the key.
A transposition/permutation key is a sequence of numbers (often generated from a word) that indicates the order in which to read or rearrange the columns of the table.
Example: The word KEY generates the permutation 2,1,3 when its letters are sorted alphabetically:
| Before alphabetical sorting | After alphabetical sorting | |
| Keyword | K,E,Y | E,K,Y |
| Column order | 1,2,3 | 2,1,3 |
If the keyword contains repeated letters, a tie-breaking rule must be defined, for example by preserving the original order of identical letters.
The columnar transposition cipher consists of writing a message in a table of width N (where N is the length of the permutation), row by row (or, depending on the variant, column by column), and then rearranging/reading the columns according to the order defined by the key. The ciphertext is obtained by reading the table in the order specified by the method (by columns or by rows).
Example: Encrypting MESSAGE using columnar transposition with the key CODE (permutation 1,3,4,2) produces MASESEG when the message is written row by row and the columns are read in the order defined by the key:
| Columns | 1,2,3,4 | Columns read | 1,3,4,2 |
| Plaintext | M,E,S,S | Ciphertext | M,S,S,E |
| A,G,E,_ | A,E,_,G |
The result depends on the convention used to fill and read the table. Some variants read the columns in a different order or read the table row by row after rearranging the columns.
If the grid contains empty cells, they can be filled with a padding/filler character, such as X, according to a convention known to the recipient. However, this changes the ciphertext and requires the decryption method to account for the padding rule.
Decrypting a columnar transposition cipher involves reconstructing the original table from the ciphertext by reversing the permutation used during encryption. The procedure depends on the order in which the table was filled and read.
If the message length (number of characters) is not a multiple of the grid width, the columns containing empty cells must be determined. This can be done by simulating the table-filling procedure used during encryption.
Example: With the permutation 2,1,3, the plaintext DCODEX can be encrypted as CDOEDX if the table is filled row by row and then read row by row after rearranging the columns:
| Original columns | 1,2,3 | Columns read | 2,1,3 |
| Plaintext | D,C,O | Text after rearrangement | C,D,O |
| D,E,X | E,D,X |
Example: The ciphertext is CDOEDX and the plaintext is DCODEX.
If the ciphertext was obtained by reading the columns, the table must be reconstructed according to the reading order and the length of each column.
Example: With the same permutation 2,1,3, reading the columns in the order 2,1,3 produces the ciphertext CEDDOX from the plaintext DCODEX:
| Original columns | 1,2,3 | Reading order | 2,1,3 |
| Plaintext | D,C,O | Columns read | C,E,D |
| D,E,X | D,O,X |
Example: The ciphertext is CEDDOX and the plaintext is DCODEX.
The ciphertext contains the same characters as the original message, but in a different order (rearrangement of characters).
The letter index of coincidence remains the same as that of the plaintext because the frequency of each letter is preserved.
In contrast, bigram frequencies (frequencies of consecutive letter pairs) generally change.
It is possible to test every permutation if the key is not too long. However, the number of possible permutations increases rapidly with the key length: for N distinct columns, there are N! possible permutations.
Another approach is to know or guess a likely word in the plaintext and then search for a permutation that produces that word.
If the ciphertext is very short or contains only one or a few words, an anagram solver may sometimes help recover the plaintext, but its effectiveness depends on the message and language.
Empty cells in the grid can make decryption more difficult and time-consuming. The recipient must determine their positions by taking into account the number of characters in the message and the filling method used. If empty cells are not explicitly represented and no preliminary calculation is performed, errors may occur when reconstructing the table, particularly for the final letters.
Filling empty cells with a padding/filler character agreed upon in advance can make manual decryption easier. However, the convention used must be known, and it must be determined whether padding characters should be removed after decryption.
dCode retains ownership of the "Transposition Cipher" source code. Any algorithm for the "Transposition Cipher" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Transposition Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Transposition Cipher" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Transposition Cipher" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Transposition Cipher on dCode.fr [online website], retrieved on 2026-11-28,