Skip to main content
Substitution ciphers100% FreeInstant

Playfair Cipher: Encrypt and Decrypt Letter Pairs

This free Playfair cipher tool builds a 5 by 5 key square from your keyword and encrypts or decrypts text two letters at a time. It shows the square and the letter pairs.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is It and When Do You Need It?

The Playfair cipher was the first practical cipher to encrypt pairs of letters. It was used in the Boer War and in both world wars. Pairs hide letter frequencies better than single-letter ciphers do.

Enter text and a keyword to see the square and the result.

How to Use This Tool

  1. Type your text.
  2. Enter a keyword.
  3. Choose encrypt or decrypt.
  4. Press Run and read the square and the pairs.

How the Calculation Works

The square is made from the unique keyword letters followed by the rest of the alphabet (J is merged into I). The plain text is cleaned to letters only and split into pairs, inserting X between a double letter and at the end if needed. Each pair is moved by the row, column or rectangle rule. Decryption reverses the moves.

Worked Example

With the keyword PLAYFAIR EXAMPLE, HIDE THE GOLD IN THE TREE STUMP becomes BMODZBXDNABEKUDMUIXMMOUVIF.

Common Uses

  • Puzzles and escape rooms.
  • Teaching digraph ciphers.
  • History of cryptography.
  • Capture-the-flag challenges.

Tips and Common Mistakes

  • Decrypted text may contain the filler X letters.
  • Remove spaces and punctuation before comparing.
  • A longer keyword mixes the square better.

Next, you may need the Vigenère cipher, Polybius square, affine cipher, rail fence cipher.

Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.

Frequently Asked Questions

The message is split into pairs of letters. In a 5 by 5 square built from the keyword, each pair is replaced by two other letters depending on whether they share a row, a column or neither.
Same row: take the letter to the right. Same column: take the letter below. Otherwise: swap to the corners of the rectangle.
A double letter pair gets an X between the letters, and an odd end gets an X added. The tool shows the pairs it used.
The square has 25 cells, so I and J share one. J is written as I.

Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.