Skip to content
100% local

Two-square cipher

Encrypt or decrypt letter pairs with two keyed Polybius squares.

Input
Output

Two-square cipher

The two-square cipher, also called double Playfair, encrypts text two letters at a time with a pair of keyed 5×5 grids instead of Playfair's single grid. Each grid holds a keyword's letters followed by the rest of the alphabet, and every letter pair is swapped for the cell at the crossing point of its two positions. Paste a message, set a key for each square, and this tool encrypts or decrypts it instantly in your browser.

Left square key and Right square key seed the two grids — leave both blank for two plain, unkeyed alphabets. Direction switches between encrypting and decrypting, with a swap button that feeds the output back in as input for a one-click round trip. Merge I and J into one cell keeps the classic 25-letter grid, since a full A-Z can't fit 5×5; turn it off and a stray J is skipped instead. Switch Alphabet to Custom for your own unique characters — any perfect-square count works, from 4×4 up to 6×6 mixing letters and digits.

Preserve spaces and punctuation keeps the layout, substituting only letters; turn it off for a dense block of paired ciphertext. Preserve letter case carries each letter's case onto its replacement, so a capitalized word still reads that way once decrypted. Show the two squares prints both grids under the result, handy for checking a key by hand. Brute-force common keys tries common English keywords instead of your own, ranking results by how English they read — a dictionary attack, not an exhaustive search, since no browser could search a real key space.

Everything runs locally: your text and keys stay on your device and are never uploaded. Copy the result, download it as a .txt file, or send the output into the input to chain another tool.

FAQ

How is the two-square cipher different from Playfair or four-square?
Playfair uses one keyed 5×5 grid for both letters of a pair; four-square uses two separate plain grids to locate the plaintext and two separate keyed grids to produce the ciphertext. The two-square cipher sits between them: it uses only two grids, but each one does double duty as both the lookup grid and the output grid for its own letter.
Why does encrypting an odd number of letters change the length?
Letters are encrypted two at a time, so an odd count gets a single filler letter appended to complete the last pair. Decrypting therefore always needs an even number of letters; an odd ciphertext means a character is missing.
What does the brute-force option actually try?
It decrypts your ciphertext with each keyword in a small built-in list of common English words (used as both squares' key) and ranks the results by how many common English letter pairs show up. It is a practical dictionary attack for a weak or guessable key, not a guarantee of finding an arbitrary one.
Can I use a custom alphabet instead of A-Z?
Yes. Switch Alphabet to Custom and type any set of unique characters whose count is a perfect square, such as a 16-character 4×4 grid or a 36-character 6×6 grid mixing letters and digits.
Is my text uploaded anywhere?
No. The cipher runs entirely in your browser using JavaScript — your text, keys and custom alphabet never leave your device.