1001Ferramentas
🔠 Security

Playfair Cipher Step by Step

Encrypt/decrypt with Playfair showing the 5×5 matrix, letter pairs and the rule applied to each digram.

Playfair: the first digram cipher actually put to use

Invented by Charles Wheatstone in 1854 and promoted by Lord Playfair, this was the first digram cipher genuinely used in the field — the British employed it in the Boer War and the First World War. Its advantage at the time was practical: encipher in your head, with paper and pencil, no equipment at all, and still escape simple frequency analysis.

Enter the key and the text and the page shows the five-by-five grid assembled and the route of each pair. The three rules: letters sharing a row are replaced by their right-hand neighbours; sharing a column, by the ones below; and in different rows and columns, each swaps to the other's column, forming a rectangle. In every case the movement wraps around when it reaches the edge of the grid.

Preparing the text has rules of its own that often confuse: repeated letters within a pair are separated by an X, because the rectangle rule breaks down when both are the same, and a trailing X closes the pair when the length is odd. That is why deciphering turns up X letters in the middle of words — they are usually padding, and reading discards them.

Frequently asked questions

Why are identical letters in a pair a problem?
Because the three rules assume distinct positions in the grid. With both letters the same, there is no rectangle, no letter to the right and no letter below that makes sense — the cipher would return the pair unchanged. Inserting an X between them fixes it, at the cost of lengthening the message.
How was Playfair broken?
By digram analysis. English, like most languages, has digrams far more frequent than others, and that distribution survives the cipher. With a few hundred characters it is possible to reconstruct part of the grid, and the row-and-column structure helps fill in the rest.
Which letter is left out of the grid?
In this version, J, replaced by I — the most common convention. Some implementations drop Q instead, which is rare in English. Whoever deciphers has to know which choice was made, or the occasional letter will come out wrong.

Related Tools