Tool to decrypt/encode with the three-square cipher which uses 3 grids to extract letters in rows or columns with a notion of randomness.
Three Squares Cipher - dCode
Tag(s) : Polygrammic Cipher, GRID_CIPHER
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
3-square encryption is done with three grids (possibly generated from a keyword or disordered alphabet)
Example: Encrypt MESSAGE with the keys ONE, TWO, THREE corresponding to the grids
(2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Split the plain message into bigrams (pairs of two letters respectively noted L1 and L2). Complete with a neutral letter of the second grid if the message has an odd length.
Find L1 in grid 1 and L2 in grid 2. Then note the intersection in grid 3 of the row of L1 in grid 1 with the column of L2 in the grid 2.
Example: For the bigram ME, M is in position (row 3, column 5) in grid 1, and E is in position (row 2, column 3) in the grid 2. The intersection in grid 3 is the letter K (row 3, column 3).
Each bigram of the plain text is associated with 3 new letters: a letter taken randomly in the same column as the letter in the grid 1, the letter intersection of the grid 3 and a letter taken randomly in the same row as the letter of the grid 2. These 3 letters (a trigram) represent the coded text for the bigram.
Example: Take T: a random letter in the column 5 (BHMTY) of the grid 1
Take K: the intersection letter of the grid 3 previously found
Take ' D ': a random letter in the row 2 (CDEFG) of the grid 2
The corresponding encrypted trigram is TKD.
Repeat the process for each bigram. The final encrypted message is TKDGNVSAFRAV.
Decryption by three squares is done with three grids.
Example: Decrypt UDBJDC with the keys ONE, TWO, THREE' corresponding to the grids
(2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Split the message into trigrams (triplets of three letters L1, L2 and L3) and find L1 in the grid 1, L2 in the grid 3 and L3 in the grid 2.
Example: The first trigram is UDB, U is in position (row 5, column 1) in grid 1, D is in position (row 2, column 3) in grid 3, and B is in position (row 1, column 5) in grid 2.
Find the 2 plain letters:
Plain letter 1: intersection of the row of the letter L2 in the grid 3 with the column of the letter L1 in the grid 1
Plain letter 2: intersection of the letter L2 column in grid 3 with the row of the letter L3 in grid 2.
Example: The first plain letter is C, intersection of row 2 of D in grid 3 with column 1 of U in grid 1.
The second plain letter is O, intersection of column 3 of D in grid 3 with row 1 of B in grid 2.
Finally the complete plain message is CODE.
The message has a length multiple of 3.
The final ciphertext is longer than the original of 33%.
The frequency analysis and the coincidence index is similar to an almost random text.
The text is theoretically composed of a maximum of 25 distinct characters if the grids are 5x5 and use the same letters of the alphabet.
In the three-square cipher, several ways of ciphering and noting the letters are possible:
The first letter of the bigram is sought in grid 1 and the second letter in grid 2, noted 1-2 (by default) but it is possible to reverse, notation 2-1.
The trigram is then generally noted as follows:
- a letter taken randomly from the same column as the letter in grid 1
- the letter from grid 3
- a letter taken randomly from the same row as the letter of the grid 2
This cipher is indicated 1-3-2 (by default). It is also possible to encrypt with a different order.
Finally, it is possible to mix the grids, such as inverting grids 1 and 2, or other permutation.
dCode retains ownership of the "Three Squares Cipher" source code. Any algorithm for the "Three Squares Cipher" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Three Squares Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Three Squares Cipher" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Three Squares Cipher" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Three Squares Cipher on dCode.fr [online website], retrieved on 2025-04-24,