Tool to encrypt and decrypt messages using the Quagmire III cipher, a polyalphabetic substitution cipher based on two keyed alphabets (plaintext and ciphertext) and a periodic keyword.
Quagmire 3 Cipher - dCode
Tag(s) : Poly-Alphabetic 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!
Quagmire III is a periodic polyalphabetic substitution cipher, related to the Vigenère cipher.
It relies on three keywords:
— The first is used to build a mixed plaintext alphabet.
— The second determines the successive shifts of the cipher alphabets and sets the repetition period.
Quagmire III belongs to the Quagmire cipher family and corresponds to plan K3.
Two methods can be used to encrypt a message.
Mathematical method: by numbering letters from A to Z from $ 0 $ to $ 25 $, encryption is expressed as $$ C = (P + K - I) \bmod 26 $$
— $ P $ is the rank of the plaintext letter in the mixed plaintext alphabet
— $ K $ is the rank of the periodic keyword letter in the mixed ciphertext alphabet
— $ I $ is the rank of the indicator letter in the mixed plaintext alphabet
— $ C $ is the rank of the encrypted letter in the mixed ciphertext alphabet
Visual method with a table:
Build the encryption table from the two mixed alphabets, the periodic keyword and the indicator letter.
Split the plaintext into blocks of $ N $ letters, where $ N $ is the length of the periodic keyword.
For each plaintext letter, locate its position in the mixed plaintext alphabet, then read the encrypted letter in the row corresponding to the periodic keyword letter.
Example: Encrypt DCODE using the mixed alphabet based on the keyword SECRET, the periodic keyword CODE (4 letters), and the indicator letter A. The first plaintext letter D corresponds to the ciphertext letter T on line 1, the second letter C encrypts to L on line 2, etc. The encrypted message is TLQRY.
— Build the mixed plaintext alphabet by writing the first keyword without its repeated letters, then adding the remaining letters of the natural alphabet in their usual order.
Example: SECRET becomes SECRT from which the plaintext alphabet SECRTABDFGHIJKLMNOPQUVWXYZ is derived
— Choose an indicator letter, usually A by convention. This letter belongs to the mixed plaintext alphabet and indicates the reference column.
— Choose a periodic keyword and build the rows of the table so that each row contains the mixed ciphertext alphabet shifted so that the periodic keyword letter appears in the indicator letter column.
Example: The periodic keyword is CODE, the indicator letter is A, the Quagmire III table is:
| Key | S | E | C | R | T | A | B | D | F | G | H | I | J | K | L | M | N | O | P | Q | U | V | W | X | Y | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| (1) | X | Y | Z | S | E | C | R | T | A | B | D | F | G | H | I | J | K | L | M | N | O | P | Q | U | V | W |
| (2) | J | K | L | M | N | O | P | Q | U | V | W | X | Y | Z | S | E | C | R | T | A | B | D | F | G | H | I |
| (3) | C | R | T | A | B | D | F | G | H | I | J | K | L | M | N | O | P | Q | U | V | W | X | Y | Z | S | E |
| (4) | W | X | Y | Z | S | E | C | R | T | A | B | D | F | G | H | I | J | K | L | M | N | O | P | Q | U | V |
Decryption is the reverse operation of encryption. It requires knowledge of the initial keyword or mixed alphabet, the periodic keyword, and the indicator letter in order to reconstruct the table.
Split the ciphertext into blocks of $ N $ letters, where $ N $ is the length of the periodic keyword.
For each encrypted letter, locate that letter in the row corresponding to the current position of the periodic keyword, then read the plaintext letter at the top of the column (mixed plaintext alphabet).
Example: The ciphertext NBDAJXAX decrypts to 'QUAGMIRE' (with the same alphabets and keyword used previously)
In the classic Vigenère cipher, the plaintext and the cipher alphabets use the natural alphabet from A to Z. Each cipher alphabet corresponds to a rotation of this alphabet.
In Quagmire III, the alphabet used to locate plaintext letters is mixed using the first keyword, while the cipher alphabet is mixed using the second keyword, and the rows are rotations of this mixed cipher alphabet.
Decryption therefore requires recovering both mixed alphabets, the periodic keyword and the indicator letter.
The markers are similar to the Vigenère cipher, but frequency analysis is made more complex by the presence of two mixed alphabets.
dCode retains ownership of the "Quagmire 3 Cipher" source code. Any algorithm for the "Quagmire 3 Cipher" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Quagmire 3 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 "Quagmire 3 Cipher" or any other element are not public (except explicit open source licence). 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 "Quagmire 3 Cipher" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
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: Quagmire 3 Cipher on dCode.fr [online website], retrieved on 2026-11-05,