Permutation Cipher

Work in progress. This note is still being written and incomplete.

One specific classical cipher in the transposition category. The category as a whole is also called permutation ciphers. This note covers the concrete construction that carries the name, in the same way the shift cipher is one concrete cipher in the mono-alphabetic category.

Reorders the plaintext letters rather than substituting them, so every single-letter frequency is preserved unchanged.

Requires a block length nn, typically small, and a permutation σSn\sigma \in S_n as the secret key.

σ=(1234524135)\sigma = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 \\ 2 & 4 & 1 & 3 & 5 \end{pmatrix}

The bottom row gives σ(i)\sigma(i) for each input position ii in the top row. Here σ(1)=2\sigma(1) = 2, σ(2)=4\sigma(2) = 4, σ(3)=1\sigma(3) = 1, σ(4)=3\sigma(4) = 3, σ(5)=5\sigma(5) = 5.

Encryption

Split the plaintext into blocks of nn characters. Pad the final block with filler characters if it is short.

Within each block, the character at position ii moves to position σ(i)\sigma(i).

cσ(i)=mic_{\sigma(i)} = m_i

Here:

  • mim_i: plaintext character at position ii in the block
  • cjc_j: ciphertext character at position jj in the block

Decryption

The receiver knows σ\sigma. Within each block, position ii of the plaintext is read from position σ(i)\sigma(i) of the ciphertext.

mi=cσ(i)m_i = c_{\sigma(i)}

This is encryption under the inverse permutation σ1\sigma^{-1}.

Attacking

Single-character frequencies in the ciphertext match the standard language distribution, since the permutation only moves characters. A ciphertext whose frequencies match the standard distribution but which does not decrypt as a substitution cipher points to a permutation cipher.

The attack recovers nn first, then σ\sigma.

Recovering the block length nn:

  • A plaintext word that repeats at the same offset within its block is permuted the same way each time, so it produces an identical character group in the ciphertext.
  • Measure the gap between the start positions of 2 such repeated groups. The gap is a multiple of nn.
  • Take the gcd of several such gaps. That gcd is nn, or a small multiple of it.

Recovering the permutation σ\sigma:

  • Cut the ciphertext into blocks of length nn.
  • Try each of the n!n! candidate permutations, applying its inverse to every block.
  • Keep the candidate that turns every block into readable text.

Worked Example

Key: σ(1)=2\sigma(1) = 2, σ(2)=4\sigma(2) = 4, σ(3)=1\sigma(3) = 1, σ(4)=3\sigma(4) = 3, σ(5)=5\sigma(5) = 5. Plaintext GETTOTHECHOPPER splits into 3 blocks of 5: GETTO, THECH, OPPER.

Encryption places mim_i at position σ(i)\sigma(i) within each block. For the first block:

  • m1=Gm_1 = \text{G} \to position 2
  • m2=Em_2 = \text{E} \to position 4
  • m3=Tm_3 = \text{T} \to position 1
  • m4=Tm_4 = \text{T} \to position 3
  • m5=Om_5 = \text{O} \to position 5

Reading positions 1 to 5: T, G, T, E, O.

The other 2 blocks follow the same rule.

  • THECH becomes ETCHH.
  • OPPER becomes POEPR.

Ciphertext: TGTEOETCHHPOEPR.

Decryption reads mim_i from position σ(i)\sigma(i) of each block, recovering GETTO, THECH, OPPER.

Plaintext: GETTOTHECHOPPER.

The attack starts from ciphertext blocks with the block length unknown. With a longer message under the same key, a plaintext word repeating at the same offset within its block would produce an identical ciphertext group each time, letting the gcd of the gaps between occurrences recover nn, as described above. Once n=5n = 5 is fixed:

  • Cut the ciphertext into blocks of 5.
  • Each of the 5!=1205! = 120 candidate permutations is applied in inverse to every block.
  • The candidate σ(1)=2\sigma(1) = 2, σ(2)=4\sigma(2) = 4, σ(3)=1\sigma(3) = 1, σ(4)=3\sigma(4) = 3, σ(5)=5\sigma(5) = 5 turns every block into readable text and is kept.
Written by September 16, 2026 4 min read
Was this helpful?