Vigenère Cipher Decoder & Substitution Cipher Solver
Decrypt, encrypt or solve Vigenère, Beaufort, Variant Beaufort and substitution ciphers (cryptograms) in your browser: key-length analysis, flag-prefix cribs, a mapping grid and a seeded solver.
Paste a ciphertext, see what the letter statistics say, then solve it or finish it by hand.
Used by analysis and solving only. Accents are folded to A-Z (é to E, ß to SS). Changing it clears earlier results.
Your text, keys and results stay in this browser tab and are not uploaded. Anonymous usage counts (which buttons are used) are sent, never your text.
How to decrypt or solve a Vigenère or substitution cipher (4 steps)
- Paste the ciphertext: Paste text, drop a .txt file (UTF-8, up to 1 MB) or load an example. Pick Decrypt or Encrypt and the cipher family. If you know the key, type it and the Result tab opens at once.
- Analyse (Vigenère family): Press Analyse to see the index of coincidence for each key length, the repeated strings and what the letter statistics suggest. These are observations with the evidence shown, not a verdict.
- Solve: Vigenère family: find the key, optionally with a key length, a partial key such as K?Y??, a known word or a flag prefix, then pick a candidate. Substitution: press Auto-solve, lock the letters you are sure of, or edit the mapping grid by hand.
- Check the result: The Result tab shows the text with any flag-shaped match highlighted, a readability indicator, the key, and a per-letter explanation. Copy it, download it, or send it to the next tool.
What This Tool Does: Two Main Workbenches and Additional CTF Operations
The tool has two main workbenches. The first is the Vigenère family (Vigenère, Beaufort, Variant Beaufort and Gronsfeld), which uses a repeating key. The second is substitution: a substitution cipher replaces each letter with another letter, always the same one. With a known key you can decrypt or encrypt. Without a key, the tool shows what the letter statistics say, recovers candidate keys and lets you finish by hand.
Beyond the two main workbenches, the Autokey panel and the More ciphers panel on the Solve tab offer additional CTF operations: Autokey, Porta, running key, columnar transposition, Playfair, Bifid, Hill, ADFGVX, Bacon, Polybius, homophonic substitution and a Vigenère with a keyed alphabet. Some are known-key operations only (Bacon, Polybius), others can also search for the key from the ciphertext. Only the two main workbenches have calibrated thresholds; every search in the additional operations is uncalibrated, lists candidates and announces no winner. The measured results are in the Limitations list.
It is built for CTF work: a flag prefix such as flag{ can be used as a known piece of plaintext, the key can be told to skip braces, digits and underscores, and results that start like a flag are highlighted. When the evidence is weak the tool says so and announces no winner instead of guessing.
Single-shift ciphers (Caesar, ROT13, ROT47) belong to the ROT / Caesar Solver; byte-level XOR belongs to the XOR Brute Forcer. This tool only handles letter ciphers.
The Vigenère Family: Vigenère, Beaufort, Variant Beaufort and Gronsfeld
With letters numbered A = 0 to Z = 25, a Vigenère key letter shifts each plaintext letter forward. Beaufort reflects the alphabet (the key minus the letter) and is its own inverse, so encrypting and decrypting are the same operation. Variant Beaufort subtracts the key, which makes it identical to Vigenère with the negated key: LEMON as a Variant Beaufort key gives the same ciphertext as PWOMN as a Vigenère key, and the tool shows that converted key so you do not search twice. Gronsfeld is Vigenère with a digit key, where each digit (0 to 9) is the shift. Recovery for it (included in this release) tries only shifts 0 to 9 at each position and flags positions whose best shift is higher as not consistent with a Gronsfeld key. Its recovery was not part of the calibration, so it never announces a winner.
Autokey replaces the repeating key with a short primer followed by the message itself: plaintext autokey continues the key stream with the plaintext, ciphertext autokey with the ciphertext (the standard example is primer QUEENLY turning ATTACKATDAWN into QNXEPVYTWTWP). In CTF mode, the Autokey panel on the Solve tab decrypts or encrypts with a known primer and searches primer lengths 1 to 32 for an unknown one, using at most the first 5,000 letters. It works on the letters A-Z only, so spaces and punctuation are not part of the result. Autokey is separate from the key-length analysis and key recovery above: it has its own panel, and its primer search is not calibrated.
Only letters of the alphabet are transformed. Digits, punctuation, spaces, braces and letters outside the alphabet pass through unchanged, and the output keeps the case of each input letter. Keys are trimmed, matched case-insensitively and rejected with the offending character named; a key may be up to 64 characters.
The Four Variants
Encryption, decryption and a real example for each variant (A = 0 … Z = 25, key LEMON).
| Variant | Encrypt | Decrypt | Example |
|---|---|---|---|
| Vigenère | C = (P + K) mod 26 | P = (C − K) mod 26 | ATTACKATDAWN + LEMON → LXFOPVEFRNHR |
| Beaufort | C = (K − P) mod 26 | Same operation (self-reciprocal) | ATTACKATDAWN + LEMON → LLTOLBETLNPR |
| Variant Beaufort | C = (P − K) mod 26 | P = (C + K) mod 26 | ATTACKATDAWN + LEMON → PPHMPZWHPNLJ |
| Gronsfeld | Vigenère with a digit key (0 = A … 9 = J) | As Vigenère | 31415 behaves like the letter key DBEBF |
Finding a Vigenère Key Without the Key
The analysis starts from the index of coincidence (IC): the chance that two letters picked from a text are equal. English prose is near 0.065 and random letters near 0.038. A repeating key flattens the IC of the whole text, but each column of letters encrypted with the same key letter is again a shifted copy of English. So for each key length k the tool splits the letters into k columns and averages their IC. The true length and its multiples score highest.
The tool lists the top lengths with their scores and tries several of them: the smallest length within 0.005 of the best score, the smallest length above the midpoint between English and random IC, and the three best by score. This ranks candidates; it does not prove the length. The Kasiski table is shown independently: repeated strings tend to sit a multiple of the key length apart, and the table lists the longest repeats with their distances and the most common factors.
For each candidate length every column is tried against all 26 key letters with a chi-square test against English letter frequencies, and the key is then refined for at most 10 passes by testing every letter at each position against a quadgram score of the full decryption. A key such as KEYKEY is reduced to its shortest period KEY. You can override any single key letter and the plaintext updates immediately.
Cribs, Partial Keys and the Flag-Prefix Trick
If you know part of the key, type it with ? for the unknown letters (K?Y??). If you know a word in the plaintext, enter 4 to 64 letters: the tool lists every position where that word is consistent with a single repeating key. At most 200 alignments are evaluated, and the page says when that limit was reached. A key list can be pasted (one key per line, up to 10,000 keys), or you can fill it with the built-in list, a small original list of common cipher, puzzle and everyday words.
A flag prefix is a crib at position 0. Take the ciphertext flag-style start ppyq{ and the prefix flag{: the first four letters give the key letters K, E, Y, K. The tool then looks for a repeat among them. Here K appears at positions 1 and 4, so it reports a weak period hint of 3 from a single matching pair; one pair can match by chance, so this is a hint, not a result.
The key-advance rule matters in CTF challenges. With Letters only (the default) the key moves only on letters, so braces, digits and underscores are skipped. With Every character the key moves on every character, including spaces and punctuation. Authors disagree, so it is a visible setting, and the same ciphertext decrypts differently under each rule.
Solving a Substitution Cipher
The mapping grid shows each cipher letter above the plain letter it stands for. You can type letters into it, lock the assignments you are sure of, undo and redo up to 200 steps, apply Atbash, a keyboard-order or reversed alphabet, a keyword alphabet or a seeded random one, and paste a 26-character key where ? means unassigned. A known word can be placed on a cipher word (for example THE on QXN): each letter pair becomes a lock. Word breaks can be kept (Aristocrat, so word patterns help) or ignored (Patristocrat, with the preview in blocks of 5 letters). In CTF mode, the option "No letter stands for itself" restricts the search to mappings where no cipher letter represents the same plain letter, as in many puzzle rules (a lock that breaks the rule is refused), and the best keys can be compared side by side with the differing characters highlighted.
Auto-solve is a seeded hill climb on a quadgram score: it starts from a frequency-matched mapping, then tries swapping and reassigning letters and keeps only changes that improve the score, restarting many times. Locks are never changed. The seed, the effort preset and the solver build are shown, so the same text, seed, effort and locks give the same result in this build unless the run is cancelled or hits the time cap. Cipher letters that do not occur in the text stay unassigned, shown as ?, because the text does not constrain them.
Three measurements are kept separate and none is a probability that the key is right: fitness (how well the decryption fits English), restart agreement (how many independent restarts reached the same mapping) and constraint consistency (a check that the result respects the locks you set; it is a constraint check, not evidence that the unlocked letters are correct).
Why the Tool Sometimes Says No Result Stands Out
Statistics need text. The thresholds for announcing a best candidate were selected using calibration runs on held-out English passages (books that are not in the reference data, checked for overlap). These measurements are published in the Learn tab; they describe performance on the tested English material, not a guarantee that a candidate is correct. The tables are published in the Learn tab. A Vigenère candidate is announced only with at least 20 letters per key position and a readability of 0.6; a substitution result needs at least 200 letters, 20% restart agreement and a readability of 0.5. Below that, the candidates are still listed with their numbers, without a winner.
Examples
Input: ATTACKATDAWN with the key LEMON
Result: Vigenère LXFOPVEFRNHR · Beaufort LLTOLBETLNPR · Variant Beaufort PPHMPZWHPNLJ
Meaning: The three variants give three different ciphertexts for the same key. Variant Beaufort PPHMPZWHPNLJ equals Vigenère with the key PWOMN.
Input: ppyq{gjkwqsgyv_ggzlcbw_ybi_der} with the key KEY (Letters only)
Result: flag{classical_ciphers_are_fun}
Meaning: The braces and underscores pass through and the key does not advance on them. Under Every character the same ciphertext decrypts to flag{izgygoior_wcbbydm_are_tat}, which is why the rule is a setting.
Input: The same ciphertext and the prefix flag{ (no key)
Result: Derived key letters KEYK · weak period hint: consistent with key length 3 (1 matching pair)
Meaning: Four letters of the key come directly from the known prefix. One repeated letter is a hint, not proof.
Input: The Vigenère example (324 letters) analysed without a key
Result: IC 0.0430 · best mean column IC 0.0762 · lengths tried 8, 4, 16, 12 · key LEMONADE (length 8, 40.5 letters per position, readability 0.94)
Meaning: A flat whole-text IC with strong column ICs points to a repeating key. Only 6 repeated strings were found, so Kasiski is weak here while the IC evidence is strong: the two are independent.
Input: flag run through Atbash; the keyword ZEBRAS
Result: flag → uozt (applying Atbash again returns flag) · ZEBRASCDFGHIJKLMNOPQTUVWXY
Meaning: Atbash is the reversed alphabet. A keyword alphabet is the keyword without repeated letters followed by the unused letters in order.
Input: The substitution example (374 letters), Standard effort, seed 41907
Result: 30 of 30 restarts completed · best key reached by 50% of them · readability 0.95 · best key announced
Meaning: The result meets the calibrated thresholds (at least 200 letters, 20% agreement, readability 0.5). Letters absent from the text stay ? in the key.
How it works
Text model
Text is processed per Unicode code point. Letters of the alphabet are transformed, everything else passes through unchanged, and the output keeps each letter's case. The default alphabet is A–Z; a custom alphabet has 2 to 64 distinct characters.
Statistics
Index of coincidence per key length, Kasiski repeats, a chi-square test for every key letter of every column, and a quadgram score from a table built from public-domain books (English by default; German, French and Spanish are selectable).
Key recovery
Per-column chi-square, then at most 10 refinement passes, reduction to the shortest period, and a ranked list of at most 5 candidates.
Substitution solver
Seeded hill climbing with restarts, locks, incremental scoring and a work budget, running in a background Worker so the page stays responsive. Cancel stops it and keeps the best key so far.
Evidence
Readability, restart agreement and locks are shown separately. A winner is announced only when calibrated thresholds are met.
What the results mean
| Result | What it means | What to do |
|---|---|---|
| Weak period hint | One pair of derived key letters repeats | Treat it as a clue and confirm with Analyse or a longer prefix |
| Text starting with a common flag format | The result contains flag{, ctf{, htb{, picoctf{ or one of your prefixes | This is a pattern match, not proof the key is right: read the text |
| No candidate stands out / No best key is announced | The numbers are shown but the calibrated thresholds were not met | Add text, give a key length, use a crib, or lock letters you are sure of |
| Incomplete run | The search was stopped, hit the work budget or hit the 60-second cap | The best key so far is shown without a winner; run again with more effort |
| Readability 0.94 | How closely the letters resemble English prose, from 0 to 1 | An indicator, not proof: code and URLs can score low with a correct key, and so can a text in a language other than the one selected |
| No strong evidence of a repeating key | No key length up to the maximum scored clearly above random | The key may be longer, or this may be another kind of cipher |
Limitations
Language support
- Languages: English is the default and the calibrated reference. German, French and Spanish models (accents folded to A-Z: é to E, ß to SS) were built from public-domain books (1,060,091, 2,134,596 and 528,679 letters) and the English thresholds were checked on held-out books of each language (20 seeds per cell): German announced 160 Vigenère and 53 substitution winners and 0 were wrong; French 160 and 57 with 0 wrong; Spanish 160 Vigenère with 0 wrong, but 1 of 50 substitution winners was wrong (above the 1% target), so Spanish substitution never announces a best key. Italian, Portuguese and non-Latin alphabets are not supported (not enough sourced text, or a different alphabet). The Porta, running-key, transposition, Playfair, Bifid, Hill, ADFGVX, Gronsfeld and Autokey searches were measured on English only. Source code, URLs or encoded data can score low even with the right key.
Primary solver reliability (Vigenère family and substitution)
- Short texts are unreliable: automatic substitution results are often wrong below about 200 letters, and Vigenère key recovery depends strongly on the letters per key position (65% to 100% exact at 12, 85% to 100% at 20, in our runs). See the measured tables in the Learn tab.
- Gronsfeld recovery was not calibrated: it lists candidates with their numbers but never announces a winner. In a test on held-out English (50 runs per cell, key lengths 3, 5 and 8; one cell is 50 runs, so a single run is 2 percentage points) the exact digit key was recovered in at least 44 of 50 runs at 12 letters per position and at least 46 of 50 at 20 or more.
Additional cipher search reliability
- Two main families plus a few extras. The tool never claims to identify a cipher type. Bacon and Polybius work with a known key only (they have almost no key: Bacon an alphabet choice, Polybius an optional keyword); ADFGVX can be decrypted with a known key or searched from the ciphertext alone. Hill (2 by 2) can derive its key from a four-letter crib or search it from ciphertext alone, and the Playfair key and the Bifid key (with a known period, or with an unknown one) are searched. A Vigenère with a keyed alphabet is exact when you know the alphabet and key, but the search for an unknown alphabet rarely succeeds. Homophonic substitution is searched when the symbols can be typed as separated tokens or characters; ciphers made of drawings or glyphs are not read. Rail-fence and other transposition layouts are not covered; only columnar transposition is.
- The extra ciphers (Porta, running key, columnar transposition) work on letters A-Z only. Their searches were not calibrated, so none announces a winner. In a test on held-out English (50 runs per cell) the Porta search ranked the exact plaintext first in at least 42 of 50 runs at 20 letters per key position and 49 of 50 at 40; the running-key search found the exact offset in 50 of 50 runs when the true key passage was in the key text; the columnar transposition search recovered the text in 50 of 50 runs for 4 and 6 columns (300 letters) and 10 of 10 for 7 columns (500 letters). These are measurements on English prose only.
- Autokey primer search was not calibrated either. In a test on held-out English (50 runs per cell, primer lengths 5 and 8, 400 and 1,500 letters) plaintext autokey recovered the exact primer in every run, and ciphertext autokey decrypted everything after the first primer-length letters exactly in every run but recovered the exact primer in none, so treat that primer as a guess. These are measurements on English prose only.
- The Hill ciphertext-only search (all 157,248 invertible 2 by 2 matrices, 20 to 1,000 letters) and the Bifid key search (annealing over key squares for a period you give, 60 to 1,000 letters) were not calibrated either. In a test on held-out English (20 runs per cell; Hill at 100 and 300 letters, Bifid at 300 and 600 letters with period 5 and a whole-message period) both recovered the exact plaintext in 20 of 20 runs in every cell. Shorter texts or other periods were not measured. When the period is unknown, a separate slower search (about 15 seconds) screens 14 periods (0, 3 to 15) and anneals the best three; at 600 letters with periods 5, 7 and a whole-message period it recovered the exact plaintext and the true period in 10 of 10 runs in every cell.
- The ADFGVX ciphertext-only search (60 to 800 plaintext characters, that is 120 to 1,600 cipher letters; columns of 2 to 7) ranks column orders by digram index of coincidence, keeps the best 4 and anneals the 6 by 6 square for each. On held-out English (20 runs per size, column keywords of 4 to 7 letters) the first candidate was the exact plaintext in 9 of 20 runs at 100 plaintext characters, 16 at 200, 13 at 400 and 10 at 700; when it failed, the result was usually far from the plaintext. It is not calibrated, so no winner is announced, and longer column keywords were not measured.
- The keyed-alphabet Vigenère search was not calibrated and rarely succeeds. On held-out English (20 runs per cell, 300 letters per key position, key lengths 2, 3 and 4) it recovered the exact text in 0 runs and at least 90% of the letters in 2, 1 and 0 of 20 runs, taking about 5, 7 and 9 seconds; treat a result as a lead, not an answer. With a known alphabet and key, Decrypt and Encrypt are exact (checked against an independent Python implementation on 200 random cases).
- The homophonic search was not calibrated. It uses simulated annealing over the symbol table with a penalty for letter frequencies that depart from English (without it many symbols collapse onto frequent letters). On held-out English (20 runs per cell, about 46 symbols for 26 letters) it recovered at least 90% of the letters in 18, 19 and 16 of 20 runs at 500, 1,000 and 2,000 symbols, and the exact text in 3, 5 and 4 of 20. Other numbers of symbols per letter were not measured.
- The Playfair key search uses simulated annealing and is probabilistic. In a test on held-out English (20 runs per size) it recovered the exact plaintext in 8 of 20 runs at 300 letters and in 17 of 20 runs at 600 letters, so a short text may need a longer sample, and no winner is announced.
Input and processing limits
- Analysis and solving need the A–Z alphabet or a permutation of it. Other alphabets support encrypt and decrypt only.
- Limits: 100,000 characters of text (a .txt file up to 1 MB), keys up to 64 characters, cribs of 4 to 64 letters, a key list of up to 10,000 keys and 1 MB, and a substitution search over the first 20,000 letters (the key is then applied to the whole text).
- The tool does not read files other than plain text. To work from a binary file, extract its strings first with the Strings Analyzer.
Security limitations
- Classical ciphers are not secure. Use the Encrypt direction for puzzles and teaching, never to protect real information.
Privacy
The tool's own code does not upload your text, keys or results: they are processed in this browser tab and are never put in the page address. The site does record which buttons you use (feature names and ranges such as text length), never your text, keys or results, and only with your analytics consent where consent applies. The language data is a static file fetched from this site. A value handed over from another CTF Lab tool arrives through IndexedDB on your device, is removed when this page reads it, and expires after 30 minutes. Your display preferences (mode, key-advance rule, solver effort) and which tabs you pinned are remembered in this browser's localStorage; your text, keys and results never are.
Frequently Asked Questions
How do I decrypt a Vigenère cipher without the key?
Paste the ciphertext, press Analyse to inspect the index of coincidence and repeated strings, then press Find the key (named Solve without the key for screen readers and on the Input tab) to list candidate keys. The tool tries the most likely key lengths, recovers each key letter by chi-square and refines the key, then lists up to five candidates with their readability. With enough text per key position the true key is usually the top candidate; with too little text it announces no winner.
How much text do I need?
It depends on the key length and on how many letters each key position gets. In our calibration run on English passages, the exact key was recovered in 65% to 100% of runs at 12 letters per key position (the lowest rate was for 5-letter keys), in 85% to 100% at 20 and in 95% to 100% at 40. At 5 letters per position it was at most 35%. The full table is in the Learn tab.
What is the flag-prefix crib?
CTF flags start with a known prefix such as flag{. If the ciphertext starts ppyq{, the first four letters give four key letters. The tool also checks them for a repeat, which can hint at the key length.
What does the Key advance setting do?
Letters only (the default) moves the key only on letters, so braces, digits and underscores are skipped. Every character moves it on every character including spaces and punctuation. Challenges differ, so try both when a flag does not appear.
How do I solve a substitution cipher (cryptogram)?
Press Auto-solve. For short texts, lock the letters you are sure of in the mapping grid and run again, or finish by hand. The page shows restart agreement and readability separately and announces a best key only when both meet thresholds measured in our calibration.
Why does it say no result stands out?
The numbers are shown, but they did not meet the thresholds, which usually means too little text. Add text, give a key length, use a crib or lock letters.
Is Variant Beaufort the same as Vigenère?
With the negated key, yes: Variant Beaufort with key K gives the same ciphertext as Vigenère with the key −K. The tool shows the converted key. Beaufort itself is different: it reflects the alphabet and is its own inverse.
Does it work with Gronsfeld, Autokey or Playfair?
Gronsfeld works with a known digit key, and this release can also recover an unknown one (each position is limited to shifts 0 to 9). Autokey (plaintext and ciphertext) works with a known primer, and in CTF mode the tool can list candidate primers of 1 to 32 letters for an unknown one. Neither recovery was calibrated, so no winner is announced. For ciphertext autokey the text after the first primer-length letters is exact once the length is right, but the primer itself is only a best guess. Playfair, Bifid, Hill, ADFGVX, Porta, running key and columnar transposition are covered by the More ciphers panel (Playfair, Bifid (known or unknown period), Hill 2 by 2 and ADFGVX have a key search from ciphertext alone; Hill can also derive its key from a four-letter crib; the ADFGVX search is not calibrated, so it announces no winner). Other ciphers are not supported in this release.
Which languages does it support?
English is the default and the reference for every threshold. German, French and Spanish can be selected: accents are folded to A-Z (é to E, ß to SS) and the statistics use a model built from public-domain books in that language. Italian, Portuguese and non-Latin alphabets are not supported. For German and French the English thresholds were checked on held-out books and announced no wrong winner; Spanish substitution never announces a best key. The figures are in the Limitations list and the Learn tab.
Can it solve a homophonic cipher, where several symbols stand for one letter?
It can search for the symbol table when you paste the symbols as separated tokens (for example numbers) or one character per symbol, at least 150 symbols and at most 80 distinct ones. The search is not calibrated and announces no winner. On held-out English with about 46 symbols for 26 letters it recovered at least 90% of the letters in most runs at 500 to 2,000 symbols but the exact text in only a few; the numbers are in the Limitations list.
Can it break a Vigenère cipher that uses a shuffled (keyed) alphabet?
If you know the alphabet and the key, the More ciphers panel encrypts and decrypts it exactly. Searching for an unknown alphabet is included, but it rarely succeeds: on held-out English it never recovered the exact text and reached 90% of the letters in at most 2 of 20 runs, so treat any result as a lead only.
Is my text uploaded?
The tool's own code does not upload your text, key or results: they stay in this browser tab. The site records which buttons are used (names and ranges, never your text), and a hand-off from another tool is kept on your device for up to 30 minutes and removed when read.
Can I share my settings or save the analysis?
Copy settings link produces a link that holds only the family, direction, variant, key-advance rule, effort and seed; it never contains your text, key, crib, flag prefix, locks or alphabet, and opening it restores those settings, not your text. Download analysis report saves a JSON file of the numbers and candidate keys from one Analyse run; it does not include your text.
Can I use it to protect a message?
No. Classical ciphers are broken by the very methods this tool uses. Use the Encrypt direction for puzzles and teaching.
Related Tools
ROT / Caesar Solver
When the key is a single letter or a pure shift
Encoding Auto-Decoder
When the result still looks like Base64 or hex
XOR Brute Forcer
When the data is bytes, not letters
Strings Analyzer
Pull strings out of a file and bring them here
Hex Viewer / Editor
Inspect the raw bytes of a text before solving it
StegSolve Online
When the ciphertext came out of an image: look through its bit planes and colour channels first
Steghide Extractor
Extract a message hidden in a JPEG or WAV with steghide, then bring the text here
Stegseek / Stegcracker Online: coming soon (test a Steghide-protected file against a wordlist, then bring the text here).