Two-Square Cipher Encoder Decoder

Encrypt and decrypt text with the two-square cipher: two keywords, two 5x5 squares, and pairs of letters.

By Hommer Zhao · Updated October 9, 2026

TL;DR
  • Two-square encrypts pairs of letters using two 5x5 squares, each mixed with a keyword.
  • There are two layouts, vertical (one square above the other) and horizontal (side by side). They give different ciphertext, so both people must choose the same one.
  • A 5x5 square cannot hold 26 letters, so choose I and J share a cell or Q omitted. The published example uses vertical with Q omitted.
  • Some pairs pass through unchanged or reversed, about 20% according to Wikipedia, which is the main weakness.
  • It is historical and educational, not secure modern encryption.
How the Two-Square Cipher Works

The two-square cipher uses two 5x5 squares. Each square starts with a keyword and continues with the remaining letters in order, skipping repeats. In the vertical layout one square sits above the other; in the horizontal layout they sit side by side.

To encrypt, split the text into pairs and, for each pair:

  1. Find the first letter in the first square (top or left) and the second letter in the second square (bottom or right).
  2. Each ciphertext letter keeps the row of its own plaintext letter and takes the column of the other one.
  3. Vertical: the first ciphertext letter is in the top square and the second in the bottom square. Horizontal: Wikipedia only states that a same-row pair comes out reversed, so this tool follows that convention by reading the first ciphertext letter from the right square and the second from the left square.

Decryption runs the same lookup in reverse. If both letters of a pair are in the same column (vertical) the pair is unchanged, and if they are in the same row (horizontal) the pair comes out reversed.

Worked Example: HELP ME OBI WAN KENOBI with EXAMPLE and KEYWORD

This is the example on the Wikipedia two-square cipher page, in the vertical layout with the Q-omitted alphabet. The steps are produced by the same functions as the tool above, so what you see is what the tool returns when you pick “Vertical” and “Q omitted”.

Step 1: build the two squares

EXAMPLE builds the top square and KEYWORD builds the bottom square.

Top (EXAMPLE)

EXAMP
LBCDF
GHIJK
NORST
UVWYZ

Bottom (KEYWORD)

KEYWO
RDABC
FGHIJ
LMNPS
TUVXZ

Step 2: split into pairs

Spaces are removed and the 18 letters are split into 9 pairs: HE LP ME OB IW AN KE NO BI.

Step 3: look up each pair

Rows and columns are counted from 1. For each pair the result is the top square at the row of the first letter and the column of the second, followed by the bottom square at the row of the second letter and the column of the first.

PairFirst letter (top)Second letter (bottom)Result
HEH: row 3, column 2E: row 1, column 2HE
LPL: row 2, column 1P: row 4, column 4DL
MEM: row 1, column 4E: row 1, column 2XW
OBO: row 4, column 2B: row 2, column 4SD
IWI: row 3, column 3W: row 1, column 4JY
ANA: row 1, column 3N: row 4, column 3AN
KEK: row 3, column 5E: row 1, column 2HO
NON: row 4, column 1O: row 1, column 5TK
BIB: row 2, column 2I: row 3, column 4DG

HE and AN come out exactly as they went in, because both letters of each pair are in the same column. These are the transparencies described below.

Step 4: join the results

The ciphertext is HEDLX WSDJY ANHOT KDG, which matches the published result.

Layout and Alphabet: What Must Match

Four settings decide the ciphertext, and both people must use the same ones:

  • Layout. Vertical or horizontal. The same keywords give different ciphertext in each.
  • Alphabet. A 5x5 square holds 25 letters. I and J share a cell (default) writes J as I, so a decrypted J comes back as I. Q omitted keeps I and J apart and drops any Q.
  • Keywords. Keyword 1 builds the top (vertical) or left (horizontal) square and keyword 2 builds the bottom or right square.
  • Keyword order. Swapping the two keywords gives a different ciphertext.

If decryption gives nonsense, a layout or alphabet mismatch is the first thing to check, because the squares look almost the same but shift letters between cells.

Examples With Real Output

Each result below is produced by the same code as the tool. Boundary cases and pitfalls are included on purpose.

Published example: help me obi wan kenobi

Encrypt HELP ME OBI WAN KENOBI with keywords EXAMPLE and KEYWORD, vertical layout, Q omitted:

HEDLX WSDJY ANHOT KDG

This is the worked example on the Wikipedia two-square cipher page (vertical layout, Q omitted). Choose "Vertical" and "Q omitted" in the tool to reproduce it.

Typical: a short message, side-by-side squares

Encrypt MEET AT NOON with keywords SECRET and MESSAGE, horizontal layout, I and J share a cell:

KTAOF NUHTI

Twelve letters make six pairs, so the result is twelve letters shown in groups of five.

Typical: decrypting with the same keywords and layout

Decrypt KTAOF NUHTI with keywords SECRET and MESSAGE, horizontal layout, I and J share a cell:

MEETATNOON

This is the ciphertext from the previous example. Decryption returns one run of capital letters without spaces.

Boundary: an odd number of letters

Encrypt HELLO with keywords EXAMPLE and KEYWORD, horizontal layout, I and J share a cell:

GXCGQ U

HELLO has five letters, so the tool appends an X to complete the last pair. The X is still there after decryption.

Limit: pairs in the same column pass through unchanged (vertical)

Encrypt HEAN with keywords EXAMPLE and KEYWORD, vertical layout, Q omitted:

HEAN

HE and AN each sit in one column of the two squares, so the ciphertext equals the plaintext. Wikipedia calls these transparencies and says about 20% of digraphs are transparent, which is the main weakness.

Limit: same-row pairs come out reversed (horizontal)

Encrypt EK with keywords EXAMPLE and KEYWORD, horizontal layout, Q omitted:

KE

E is in row 1 of the first square and K is in row 1 of the second, so the pair comes out reversed as KE. Wikipedia gives this as the convention for the horizontal layout.

Limit: J becomes I in the default alphabet

Encrypt JUMP JETS with keywords EXAMPLE and KEYWORD, horizontal layout, I and J share a cell:

GWYSG AST

With I and J sharing one cell, decrypting this ciphertext returns IUMPIETS. The reader has to restore the J from context.

Limit: Q is dropped in the Q-omitted alphabet

Encrypt QUIZ TIME with keywords EXAMPLE and KEYWORD, horizontal layout, Q omitted:

XGTZG RWU

The Q has no cell, so it is removed before encryption; the remaining seven letters get an X to make a full last pair.

Pitfall: the wrong layout

Encrypt MEET AT NOON with keywords SECRET and MESSAGE, vertical layout, I and J share a cell:

IGRQF PUIQK

The same text and keywords as the typical example, but with the vertical layout, give a different ciphertext. Decrypting with the other layout does not recover the message.

Pitfall: keywords in the wrong order

Encrypt MEET AT NOON with keywords MESSAGE and SECRET, horizontal layout, I and J share a cell:

EMTET AITHU

The same text and the same two keywords in the opposite order give a different ciphertext.

Pitfall: punctuation and digits are dropped

Encrypt Hello, World! 123 with keywords EXAMPLE and KEYWORD, horizontal layout, I and J share a cell:

GXCGQ EMLDL

Only letters are encrypted, so the comma, exclamation mark and digits are removed and cannot come back.

History and Strength

According to Wikipedia, Félix Delastelle described the cipher in his 1901 book Traité élémentaire de cryptographie under the name “damiers bigrammatiques réduits” (reduced digraphic checkerboard), with both horizontal and vertical types. William F. Friedman later described it as the “two-alphabet checkerboard” in Advanced Military Cryptography (1931), and it became a regular puzzle type in the American Cryptogram Association after a 1972 description in The Cryptogram. For Delastelle himself, see Wikipedia, Félix Delastelle.

Its weakness is the transparency: Wikipedia says about 20% of digraphs are transparent, that cryptanalysis almost always revolves around this, and that the cipher can be cracked easily when there is enough text and is weaker than the double transposition cipher. Use it for learning, puzzles and clues, not for secrets.

Frequently Asked Questions

What is the two-square cipher?

The two-square cipher is a manual cipher that encrypts text two letters at a time using two 5x5 squares, each mixed with a keyword. Felix Delastelle described it in 1901 under the name "damiers bigrammatiques reduits" (reduced digraphic checkerboard).

How do I encrypt a pair of letters?

Split the text into pairs. Find the first letter in the first square and the second letter in the second square. Each ciphertext letter keeps the row of its own plaintext letter and takes the column of the other one: the first ciphertext letter comes from the row of the first letter and the column of the second letter, and the second ciphertext letter from the row of the second letter and the column of the first letter.

What is the difference between the vertical and the horizontal layout?

In the vertical layout one square sits above the other, and the first ciphertext letter is read from the top square. In the horizontal layout the squares sit side by side. Wikipedia states only that a same-row pair comes out reversed, so this tool follows that convention and reads the first ciphertext letter from the right square. Other tools may order the horizontal output differently. The layouts give different ciphertext for the same keywords, so both people must choose the same layout.

Which keyword goes in which square?

In this tool, keyword 1 builds the top square (vertical) or the left square (horizontal), and keyword 2 builds the bottom or right square. Both must be entered in the same order to decrypt. Swapping them gives a different ciphertext.

Why can I choose between "I and J share a cell" and "Q omitted"?

A 5x5 square holds 25 letters, so one of the 26 has to be left out. The default merges I and J, so J is written as I. The Q-omitted option keeps I and J apart and drops Q. The Wikipedia worked example uses the Q-omitted alphabet, so select it, with the vertical layout, to reproduce that example. Both parties must use the same choice.

Why do some pairs come out unchanged or reversed?

In the vertical layout a pair whose two letters are in the same column encrypts to itself. In the horizontal layout a pair whose two letters are in the same row comes out reversed. Wikipedia calls this a transparency and says about 20% of digraphs are transparent, which is a weakness that helps a codebreaker.

Why did my spaces, punctuation and digits disappear?

Only the letters A to Z are placed in the squares. Spaces, punctuation and digits are removed before encryption, and lower case becomes upper case, so decryption returns one run of capital letters.

Why is there an X at the end of my decrypted text?

Encryption works on pairs. If the text has an odd number of letters, the tool appends an X so the last pair is complete. That X is part of the ciphertext and appears again when you decrypt.

Is the two-square cipher secure?

No, not for modern use. Wikipedia notes that it can be easily cracked if there is enough text and that it is weaker than the double transposition cipher. Treat it as a historical and educational cipher.

Related methods: the Four-Square cipher, the Playfair cipher, the Polybius square and the Bifid cipher.