Skip to content
UniKit

Four-square cipher

Build the four 5×5 squares of the Four-square cipher from two keywords, encrypt or decrypt English digraph text, and inspect all four squares.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Keyword presets
Ciphertext
The four squares
Top-left (standard)
ABCDEFGHIKLMNOPQRSTUVWXYZ
Top-right (keyword 1)
EXAMPLBCDFGHIKNOQRSTUVWYZ
Bottom-left (keyword 2)
KEYWORDABCFGHILMNPQSTUVXZ
Bottom-right (standard)
ABCDEFGHIKLMNOPQRSTUVWXYZ

What this tool does

  • Work through a classical-cipher exercise or an entry-level CTF puzzle: give two keywords and see the ciphertext plus every intermediate step.
  • Check the Four-square cipher by hand — the tool prints all four 5×5 squares and the prepared digraph text.
  • Decrypt a ciphertext someone handed you: paste it with the same keywords and optionally strip the filler X.
  • Explain why doubled letters need a filler: seeing HELLO WORLD prepared as HE LX LO WO RL DX makes the reason obvious.

Example

Input

Plaintext HELLO WORLD, keywords EXAMPLE / KEYWORD, encrypt mode

Output

FY IT KF YG OG AX (continuous: FYITKFYGOGAX); prepared plaintext HE LX LO WO RL DX

The alphabet merges I/J, and both doubled letters and an odd tail are padded with X. A trailing X cannot be told apart from a real one, so "remove filler X" only strips an X sitting between two identical letters.

Frequently asked questions

Why did HELLO become HELXLO?

The cipher works on two-letter groups, and a group with two identical letters would encrypt to itself, giving away the pair. Inserting the filler X breaks that up. For the same reason an odd-length plaintext gets one X appended to complete the last group.

Why is there no J in the squares?

A 5×5 grid has only 25 cells, so the classic convention merges I and J and treats every J as I. Typing J in a keyword therefore behaves as I, and J never appears in the output.

Can I use any keywords?

You need at least one letter. Non-letters are ignored, repeated letters are dropped, case is ignored, and the remaining cells are filled from the standard alphabet. Identical keywords still work but weaken the cipher — pick two different words.

Can the trailing X be removed after decryption?

Not reliably, and the tool does not guess. A padding X at the end is indistinguishable from a real X in the message, so the "remove filler X" option only handles an X between two identical letters; the rest is up to you.

Is the Four-square cipher secure today?

No. It is a paper-and-pencil classical cipher that falls to digraph frequency analysis. Treat it as a teaching aid, puzzle or toy — never use it to protect real data.

Keywords:four squarecipherencryptdecrypt四方密码加密解密digraph古典密码keyword

Related tools