Quagmire

Quagmire Cipher: ACA's Advanced Polyalphabetic System with 4 Variants Explained

Master the Quagmire cipher family — the American Cryptogram Association's 4-variant polyalphabetic system. Learn how keyed alphabets improve on Vigenère, with step-by-step encryption examples and cryptanalysis methods.

Published March 19, 2026
15 minute read
Cryptography Guide

Introduction: What Makes the Quagmire Cipher Special

The Vigenere cipher is the most famous polyalphabetic cipher in history, but it has a well-known structural weakness: every substitution alphabet it uses is simply the standard alphabet shifted by some number of positions. The relative order of letters never changes. An E shifted by five positions becomes a J, and every other letter in that alphabet shifts by exactly five as well. This regularity means that once a cryptanalyst determines the keyword length and isolates each individual alphabet, the problem reduces to breaking a set of simple Caesar ciphers -- a trivial exercise.

The Quagmire cipher family was designed to eliminate this weakness. Instead of shifted standard alphabets, the Quagmire system uses keyword-mixed alphabets -- alphabets where the letter order has been scrambled by a keyword before any shifting occurs. This single change dramatically complicates frequency analysis. The letter relationships that make Vigenere vulnerable no longer hold. A cryptanalyst who determines the keyword length and isolates a single alphabet still faces a mixed-alphabet substitution cipher rather than a simple shift, and mixed alphabets are orders of magnitude harder to crack.

The Quagmire family consists of four variants, designated Types I through IV, each differing in which alphabets (plaintext, ciphertext, or both) are keyword-mixed. This classification system was formalized by the American Cryptogram Association (ACA), the oldest and most active recreational cryptography organization in the United States. The four variants provide a graduated scale of complexity and security, from the relatively approachable Quagmire I to the formidable Quagmire IV.

Try our free Quagmire Cipher tool to encrypt and decrypt messages using all four variants.


History and the ACA Classification

Why "Quagmire"?

The name is deliberately evocative. A quagmire is a soft, boggy area of land that gives way underfoot -- a place where you get stuck. The cipher family earned this name because cryptanalysts attempting to break these systems would find themselves mired in the complexity of keyword-mixed alphabets. Unlike the Vigenere cipher, where determining the period reduces the problem to a set of Caesar shifts, breaking a Quagmire cipher requires recovering the keyword-mixed alphabet itself, a substantially harder task that can feel like sinking into intellectual quicksand.

The American Cryptogram Association

The ACA was founded in 1930 and has served continuously since then as a community for recreational cryptographers -- people who solve and construct ciphers as an intellectual pursuit. The organization publishes a bimonthly journal, The Cryptogram, which features cipher challenges in dozens of different cipher types. The ACA developed a systematic classification of cipher families, and the Quagmire designation became the standard way to refer to periodic polyalphabetic ciphers that use keyword-mixed alphabets.

The four Quagmire types were not invented by a single person at a single moment. Rather, they represent the ACA's formalization of cipher constructions that had been used in various forms since at least the nineteenth century. The concept of mixing an alphabet with a keyword dates back to early substitution cipher practice, and the idea of combining mixed alphabets with periodic polyalphabetic systems evolved gradually. The ACA's contribution was to name these systems, classify them into four distinct types, and establish standard conventions for their construction and notation -- making it possible for cryptographers to communicate precisely about which variant they were discussing.

Evolution from Vigenere

The Quagmire family sits in a clear evolutionary line. The Vigenere cipher (1586) introduced the repeating keyword and the tabula recta. The Beaufort cipher modified the mathematical operation from addition to subtraction. The autokey cipher addressed the repeating-keyword vulnerability by incorporating plaintext into the key stream. The Quagmire family addresses a different weakness: the regularity of the substitution alphabets themselves. By mixing the alphabets, the Quagmire ciphers retain the operational structure of the Vigenere (repeating keyword, periodic substitution) while substantially increasing resistance to frequency-based attacks.


The Four Quagmire Variants Explained

All four variants share a common structure: a plaintext alphabet, a ciphertext alphabet, and an indicator keyword that controls the periodic shifting. What distinguishes them is which of the alphabets are keyword-mixed and which are standard (straight A-Z).

Quagmire I: Keyed Plaintext, Straight Ciphertext

In Quagmire I, the plaintext alphabet is constructed using a keyword, while the ciphertext alphabet remains the standard A-Z ordering. The indicator keyword determines how many cipher alphabets are generated and their rotation.

Configuration:

  • Plaintext alphabet: Keyword-mixed
  • Ciphertext alphabet: Standard (ABCDEFG...XYZ)
  • Keywords required: 1 alphabet keyword + 1 indicator keyword

How it works: The keyed plaintext alphabet changes the mapping between "what position a letter occupies" and "what letter it is." When the standard ciphertext alphabets are shifted according to the indicator, the resulting substitution is no longer a simple Caesar shift of the standard alphabet -- it is a Caesar shift applied to the mixed alphabet, producing a much less predictable mapping.

Quagmire II: Straight Plaintext, Keyed Ciphertext

Quagmire II reverses the configuration of Type I. The plaintext alphabet is standard, while the ciphertext alphabet is keyword-mixed.

Configuration:

  • Plaintext alphabet: Standard (ABCDEFG...XYZ)
  • Ciphertext alphabet: Keyword-mixed
  • Keywords required: 1 alphabet keyword + 1 indicator keyword

How it works: Here, the plaintext letters are read from their standard positions, but the ciphertext values they map to come from a scrambled alphabet. The effect on security is similar to Quagmire I -- frequency relationships are disrupted -- but the attack surface differs slightly. Quagmire II is essentially equivalent to the Vigenere cipher when no alphabet keyword is used (i.e., when the ciphertext alphabet is also standard).

Quagmire III: Same Keyed Alphabet for Both (The Keyed Vigenere)

Quagmire III is the most widely used variant. It uses the same keyword-mixed alphabet for both plaintext and ciphertext positions. This is sometimes called the Keyed Vigenere cipher because it extends the Vigenere concept with a single keyed alphabet that serves double duty.

Configuration:

  • Plaintext alphabet: Keyword-mixed
  • Ciphertext alphabet: Same keyword-mixed alphabet
  • Keywords required: 1 alphabet keyword + 1 indicator keyword

How it works: Because both the plaintext and ciphertext use the same keyed alphabet, the system has an elegant symmetry. The indicator keyword shifts the keyed alphabet against itself, creating substitution tables where mixed-alphabet positions map to other mixed-alphabet positions. This variant strikes the best balance between security and usability, which explains its popularity in ACA competitions and geocaching puzzles.

Quagmire IV: Two Different Keyed Alphabets

Quagmire IV is the most complex and secure variant. It uses two independently keyword-mixed alphabets -- one for plaintext and a different one for ciphertext.

Configuration:

  • Plaintext alphabet: Keyword-mixed (keyword 1)
  • Ciphertext alphabet: Keyword-mixed (keyword 2, different from keyword 1)
  • Keywords required: 2 alphabet keywords + 1 indicator keyword (3 total)

How it works: With two independent keyed alphabets, the substitution tables are maximally complex. Recovering one alphabet does not help with the other, and a cryptanalyst must solve for both mixed alphabets simultaneously. This makes Quagmire IV the hardest variant to break without a substantial crib.

Quick Reference Table

FeatureQuagmire IQuagmire IIQuagmire IIIQuagmire IV
Plaintext alphabetKeyedStandardKeyedKeyed (Key 1)
Ciphertext alphabetStandardKeyedKeyed (same)Keyed (Key 2)
Total keywords needed2223
Security levelGoodGoodBetterBest
ACA difficulty ratingModerateModerateChallengingVery challenging
Best suited forLearningVariationGeneral useMaximum security

Step-by-Step Encryption: Quagmire III Example

Let us work through a complete Quagmire III encryption to see exactly how the system operates.

Setup:

  • Plaintext message: ATTACK AT DAWN
  • Alphabet keyword: CIPHER
  • Indicator keyword: KEY

Step 1: Construct the Keyed Alphabet

Take the alphabet keyword CIPHER. Write its unique letters first, then append the remaining alphabet letters in standard order:

Keyword letters (deduplicated):  C I P H E R
Remaining alphabet letters:      A B D F G J K L M N O Q S T U V W X Y Z
Keyed alphabet:                  C I P H E R A B D F G J K L M N O Q S T U V W X Y Z
Position:                        0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Since this is Quagmire III, the same keyed alphabet CIPHERABDFGJKLMNOQSTUVWXYZ is used for both plaintext and ciphertext.

Step 2: Generate the Cipher Tableaux

The indicator keyword KEY has three letters, so we generate three shifted versions of the keyed alphabet. Each indicator letter determines the shift amount by finding its position in the keyed alphabet:

  • K is at position 12 in the keyed alphabet, so we shift the alphabet left by 12 positions.
  • E is at position 4, so we shift left by 4.
  • Y is at position 24, so we shift left by 24.
Keyed alphabet: C I P H E R A B D F G J K L M N O Q S T U V W X Y Z
[K] Shift 12:   K L M N O Q S T U V W X Y Z C I P H E R A B D F G J
[E] Shift 4:    E R A B D F G J K L M N O Q S T U V W X Y Z C I P H
[Y] Shift 24:   Y Z C I P H E R A B D F G J K L M N O Q S T U V W X

Step 3: Encrypt Each Letter

Remove spaces from the plaintext: ATTACKATDAWN. Align the indicator keyword cyclically:

Indicator:  K  E  Y  K  E  Y  K  E  Y  K  E  Y
Plaintext:  A  T  T  A  C  K  A  T  D  A  W  N

For each plaintext letter, find its position in the keyed alphabet, then look up the corresponding letter in the appropriate shifted alphabet:

PositionPlainIndicatorPlain Position in Keyed AlphabetCipher (from shifted alphabet)
1AK6 (A is at position 6)S
2TE19 (T is at position 19)X
3TY19Q
4AK6S
5CE0 (C is at position 0)E
6KY12G
7AK6S
8TE19X
9DY8A
10AK6S
11WE22C
12NY15L

Result:

Plaintext:  A T T A C K A T D A W N
Indicator:  K E Y K E Y K E Y K E Y
Ciphertext: S X Q S E G S X A S C L

The encrypted message is SXQSEGSXASCL.

Step 4: Verify by Decryption

To decrypt, reverse the process: for each ciphertext letter, find its position in the appropriate shifted alphabet, then look up the letter at that position in the keyed alphabet.

  • Position 1: S is at position 6 in the [K]-shifted alphabet. Position 6 in the keyed alphabet is A. Correct.
  • Position 2: X is at position 19 in the [E]-shifted alphabet. Position 19 in the keyed alphabet is T. Correct.

The decryption recovers the original message.


Keyed Alphabet Construction Method

The keyed alphabet is the foundation of all Quagmire variants. Here is the precise algorithm:

  1. Choose a keyword. For example: CRYPTOGRAPHY.
  2. Convert to uppercase and remove duplicate letters, keeping only the first occurrence of each. C-R-Y-P-T-O-G-R-A-P-H-Y becomes CRYPTOGAH (the second R, P, and Y are dropped).
  3. Append remaining alphabet letters in standard order: B, D, E, F, I, J, K, L, M, N, Q, S, U, V, W, X, Z.
  4. Final keyed alphabet: CRYPTOGAHBDEFIJKLMNQSUVWXZ.

This method produces a simple deranged alphabet -- one where no letter necessarily occupies its original position, and the degree of derangement depends on the keyword. Longer keywords with more unique letters produce more thoroughly mixed alphabets.

Choosing Good Keywords

Not all keywords are equally effective:

  • Longer keywords with many unique letters produce better mixing. A 10-letter keyword with 10 unique letters displaces more of the alphabet than a 4-letter keyword.
  • Avoid short or common words. A keyword like "CAT" only displaces three letters, leaving most of the alphabet in its standard order.
  • Letters from across the alphabet produce more disruption. A keyword like "JUXTAPOSED" (which contains letters from several regions of the alphabet) creates more mixing than "ABCDEF" (which merely shifts the beginning).
  • The indicator keyword should also be chosen carefully. Its length determines the cipher's period, and longer periods generally increase security.

Cryptanalysis of Quagmire Ciphers

Step 1: Determine the Period (Keyword Length)

The first stage of any Quagmire cryptanalysis is identical to breaking the Vigenere: determine the length of the indicator keyword.

Kasiski Examination. Search the ciphertext for repeated sequences of three or more letters. When the same plaintext fragment happens to align with the same indicator keyword position at two different points in the message, the resulting ciphertext will be identical. The distances between these repetitions are multiples of the indicator keyword length. Finding the greatest common divisor of several such distances usually reveals the period.

Index of Coincidence (IC). Split the ciphertext into groups based on a hypothesized period length. If the period is correct, each group will have been encrypted with a single shifted alphabet, and its IC will approximate the IC of natural English text (approximately 0.0667). If the period is wrong, the IC will be closer to the random baseline (approximately 0.0385). Test several candidate periods and choose the one that yields the highest average IC across all groups.

Step 2: Recover the Indicator Key

Once the period is known, split the ciphertext into groups where each group was encrypted with the same shifted alphabet. For Quagmire II and III, chi-squared testing against expected English letter frequencies can help determine the shift for each group. This step is similar to Vigenere key recovery, but the mixed alphabet means the frequency distribution will not match a simple shift of the English distribution -- it will be a permuted version.

For Quagmire I and IV, the mixed alphabet complicates matters further. The frequency distribution of each group reflects both the shift and the alphabet mixing, making direct frequency matching unreliable without additional information.

Step 3: Crib Analysis

A crib is a known or suspected plaintext fragment. Crib analysis is the most powerful technique against Quagmire ciphers, especially Types I and IV where frequency analysis alone is insufficient.

If you suspect that the plaintext contains the word "THE" (an excellent guess for English text), you can:

  1. Try placing "THE" at every possible position in the ciphertext.
  2. For each placement, calculate what the alphabet keyword and indicator keyword values would need to be.
  3. Check whether those values are consistent with other positions that share the same indicator keyword letter.
  4. Consistent values narrow down both the alphabet keyword and the indicator keyword simultaneously.

Step 4: Alphabet Recovery

The final challenge -- unique to Quagmire ciphers -- is recovering the keyword-mixed alphabet. Once enough indicator-key/plaintext-ciphertext pairs are established, the mixed alphabet can be reconstructed. Each known pair reveals one mapping in the alphabet. With enough mappings, the keyword that generated the alphabet can often be deduced by recognizing the pattern: a block of keyword letters followed by the remaining alphabet in order.

Difficulty by Variant

VariantCryptanalytic DifficultyKey Challenge
Quagmire IModerateOne mixed alphabet to recover
Quagmire IIModerateOne mixed alphabet to recover
Quagmire IIIChallengingOne mixed alphabet, used twice
Quagmire IVVery challengingTwo independent mixed alphabets

Quagmire vs. Vigenere vs. Beaufort: Comparison

PropertyVigenereBeaufortQuagmire IQuagmire IIIQuagmire IV
Alphabet typeStandard shiftedStandard shiftedMixed plain, standard cipherSame mixed alphabetTwo different mixed alphabets
Encryption formulaC = (P + K) mod 26C = (K - P) mod 26Keyed substitution + shiftKeyed substitution + shiftDouble keyed substitution + shift
Self-reciprocalNoYesNoNoNo
Vulnerable to simple frequency analysisYes (per-group)Yes (per-group)Partially resistantResistantHighly resistant
Kasiski examinationEffectiveEffectiveEffective (for period)Effective (for period)Effective (for period)
Keys required11223
Key space (relative)SmallSmallMediumMediumLarge
Practical securityLowLowModerateGoodVery good

The critical difference is what happens after the period is determined. Against Vigenere and Beaufort, each group reduces to a Caesar cipher that frequency analysis solves instantly. Against Quagmire ciphers, each group is a mixed-alphabet substitution that requires substantially more text, more sophisticated analysis, or a crib to break.


Practical Uses Today

Geocaching Puzzles

The Quagmire cipher is a favorite among geocaching puzzle creators. The combination of multiple keywords and four variant types gives puzzle designers considerable flexibility. Quagmire III is particularly popular because it offers genuine difficulty for solvers while remaining tractable with the right approach. Many geocaching puzzles provide a partial crib (such as the expected format of GPS coordinates) that makes the cipher solvable with effort.

ACA Competitions

The American Cryptogram Association features Quagmire ciphers regularly in The Cryptogram journal. Members submit and solve ciphers across all four types, with difficulty ratings that reflect the variant and the length of the ciphertext. Quagmire IV challenges are considered among the most difficult standard cipher types in ACA competition, and successful solutions earn considerable respect in the community.

Cryptography Education

The Quagmire family is excellent for teaching several fundamental concepts:

  • The importance of alphabet construction in substitution cipher security.
  • The progression from simple to complex polyalphabetic systems.
  • Why key space matters -- comparing Types I through IV demonstrates how additional keys increase security.
  • The limits of classical ciphers -- even Quagmire IV falls to modern computational attacks, illustrating why we need fundamentally different approaches (like AES) for real security.

CTF (Capture the Flag) Challenges

Quagmire ciphers appear in cybersecurity CTF competitions, particularly at intermediate difficulty levels. They test a competitor's ability to identify the cipher type, determine the variant, and apply appropriate cryptanalytic techniques. The presence of four variants adds an identification challenge that simpler ciphers do not provide.


Frequently Asked Questions

What is the difference between a Quagmire cipher and a Vigenere cipher?

The Vigenere cipher uses only standard (shifted) alphabets -- every substitution alphabet is just the normal A-Z sequence rotated by some amount. The Quagmire cipher family uses keyword-mixed alphabets, where the letter order has been scrambled before shifting. This means that even after a cryptanalyst determines the period and isolates individual alphabets, each alphabet is a mixed-letter substitution rather than a simple shift. Breaking a mixed alphabet requires far more ciphertext and more sophisticated techniques than breaking a Caesar shift, which is why Quagmire ciphers are significantly more secure than Vigenere.

Which Quagmire variant should I use?

For most purposes, Quagmire III (the Keyed Vigenere) offers the best balance of security and simplicity. It uses a single keyed alphabet for both plaintext and ciphertext, which means you only need to remember two keywords: one for the alphabet and one for the indicator. If you need maximum security and do not mind managing three keywords, Quagmire IV provides the strongest protection. Quagmire I and II are primarily of historical and educational interest.

How many keywords does each Quagmire variant require?

Quagmire I, II, and III each require two keywords: one alphabet keyword (to generate the mixed alphabet) and one indicator keyword (to control the periodic shifting). Quagmire IV requires three keywords: two alphabet keywords (one for the plaintext alphabet, one for the ciphertext alphabet) and one indicator keyword.

Can Quagmire ciphers be broken by computer?

Yes. While Quagmire ciphers are harder to break than Vigenere, they are not immune to computational attack. A computer can determine the period using the Index of Coincidence, then apply hill-climbing algorithms or genetic algorithms to search for the keyword-mixed alphabet. With sufficient ciphertext (typically several hundred characters), automated solvers can recover the key. Quagmire IV is the most resistant to automated attack because two independent alphabets must be recovered, but it too can be broken given enough material. No classical cipher provides real security against modern computational resources.

What does "indicator keyword" mean in the Quagmire system?

The indicator keyword (sometimes called the "indicator key" or simply the "indicator") is the keyword that controls the periodic shifting of the cipher alphabets. It functions exactly like the keyword in a standard Vigenere cipher: each letter of the indicator selects a particular shift (or rotation) of the cipher alphabet. The indicator's length determines the cipher's period -- a 5-letter indicator creates a period of 5, meaning the substitution pattern repeats every 5 characters. The indicator keyword is distinct from the alphabet keyword(s) that generate the mixed alphabet(s).

Why is Quagmire III called the "Keyed Vigenere"?

Quagmire III is called the Keyed Vigenere because it extends the standard Vigenere cipher by replacing the straight alphabet with a keyword-mixed (keyed) alphabet. The operational procedure is the same as Vigenere -- align a repeating indicator keyword with the plaintext and look up substitutions in a tableau -- but the tableau is built from the keyed alphabet rather than the standard A-Z sequence. The "keyed" prefix distinguishes it from the standard Vigenere while acknowledging the direct lineage.

How does the Quagmire cipher relate to ACA cipher types?

The American Cryptogram Association (ACA) maintains a classification system for dozens of cipher types. The Quagmire family occupies a specific category: periodic polyalphabetic ciphers with keyword-mixed alphabets. The ACA assigns each variant a distinct type number (I through IV) and publishes challenge ciphers in each type regularly. Many ACA members specialize in particular cipher types, and the Quagmire variants -- especially Types III and IV -- are considered among the more prestigious challenges to solve.


Start Encrypting with the Quagmire Cipher

The Quagmire cipher family represents one of the most sophisticated achievements in classical polyalphabetic encryption. By combining keyword-mixed alphabets with periodic substitution, it addresses the fundamental weakness that makes the Vigenere cipher breakable while retaining the elegance and usability of the polyalphabetic framework.

Ready to try it yourself? Use our Quagmire Cipher encoder to encrypt messages with all four variants, or test your cryptanalysis skills with the Quagmire Cipher decoder to break Quagmire-encrypted messages using crib analysis and automated solving techniques.

About This Article

This article is part of our comprehensive quagmire cipher tutorial series. Learn more about classical cryptography and explore our interactive cipher tools.

Try Quagmire Cipher Cipher Tool

Put your knowledge into practice with our interactive quagmire cipherencryption and decryption tool.

Try Quagmire Cipher Tool