Toolstia / Playfair cipher

Playfair cipher

The Playfair cipher encrypts pairs of letters using a 5 by 5 square built from a keyword. It was used in the field in the early 20th century. Enter a keyword and a message to encrypt it, or paste ciphertext to decrypt it, and see the key square.

Letters are paired up. Doubled letters in a pair get a filler between them, and J is treated as I. Decrypted text may contain filler letters you will need to read past.

How it works

  1. Choose encrypt or decrypt and enter the keyword.
  2. Type the message or ciphertext.
  3. Copy the result and keep the key square for reference.

Building the square

Write the keyword without repeated letters, then the rest of the alphabet. I and J share one cell, so J is treated as I.

The three rules

Two letters in the same row each move one place right. In the same column each moves one down. Otherwise each takes the letter in its own row and the other letter column, forming a rectangle.

Doubled letters

If a pair would be two of the same letter, a filler letter is put between them. A single letter left at the end is also paired with the filler.

Reading the result

Decrypting gives the message with any filler letters still in it and no spaces, so you read past them.

Questions

Is Playfair secure?

No. It can be broken with letter pair statistics and is only a classic puzzle cipher. Everything happens in your browser, and nothing you enter is sent anywhere.

Why was my J changed?

The square has 25 cells, so I and J share one. After decrypting, a letter I may have been a J.

Why does decrypting fail with an odd length?

Ciphertext is made of pairs, so it must have an even number of letters.