DevTools Logo

Vigenère Cipher Tool

Vigenère Cipher Tool

Encrypt, decrypt and analyze Vigenère ciphers with index-of-coincidence and key-length hints.

Runs in your browser

A polyalphabetic keyed cipher: each plaintext letter is shifted by the next keyword letter, and the key stream advances only on letters. Spaces, digits and punctuation pass through untouched, and per-letter case is preserved by default. The analysis mode computes the index of coincidence (English prose is around 0.0667, random text around 0.0385), ranks candidate periods by average coset IoC, and offers per-position key-letter guesses from chi-squared fit. Pick a period, edit any suggested key letter, and watch the trial plaintext update. This is a classical cipher with no modern security — a teaching and puzzle tool, entirely in your browser.

Mode

Classical cipher — educational only. It provides no modern security; exercise text stays in this tab.

Try an example

Text

Ciphertext

No result yet

Type text, choose a mode, then load an example to see the workflow.

Examples

Classic vector

Input
ATTACKATDAWN / LEMON
Output
LXFOPVEFRNHR

The textbook Vigenère example; decrypting with the same key returns the plaintext.

Passthrough

Input
Attack at dawn! / lemon
Output
Lxfopf at fqhr!

The space and exclamation mark are untouched and do not advance the key stream; original casing is kept.

Index of coincidence

Input
English prose ≈ 0.0667; random letters ≈ 0.0385
Output
Higher IoC suggests a monoalphabetic-like distribution within each coset

A correctly guessed period splits a Vigenère ciphertext into cosets whose IoC rises toward English.

Key-length hint

Input
Ciphertext with a 5-letter key
Output
Period 5 ranks near the top of the suggestions

The suggester uses averaged coset IoC (Friedman-style), not Kasiski repeated-segment distances.

About this tool

The Vigenère Cipher Tool encrypts and decrypts keyword-shifted text, then goes one step further with cryptanalysis. Each letter is shifted by the next keyword letter (encryption adds the shift, decryption subtracts it), and the key stream advances only on A–Z characters. Spaces, digits and punctuation pass through untouched.

Analysis mode computes the index of coincidence over the ciphertext's letters: English prose typically scores near 0.0667 while random text scores near 0.0385. Candidate periods are ranked by the average IoC of their cosets (letters at positions i mod period). Pick a period to see per-position frequency counts, chi-squared key-letter guesses and a live trial decryption you can correct by hand.

Casing is preserved per source letter by default, with a lowercase-output option. This is a classical cipher with no security value: the tool is for coursework, CTF puzzles and demonstrations, runs entirely in the browser, and keeps exercise text in the tab.

What this tool does not do

  • The cipher is classical and insecure; the tool makes no modern security claims.
  • Only ASCII A–Z letters are encrypted or analyzed; accented letters are treated as non-alphabetic and pass through.
  • Key-length ranking uses averaged coset IoC; it can over-report multiples of the true period on short texts.
  • Per-position key guesses assume English letter frequencies and need enough ciphertext per coset to be reliable.
  • The tool does not auto-break ciphers end-to-end — key suggestions require manual confirmation.

How to use this tool

  1. Choose a mode

    Encrypt, Decrypt or Analyze. Codec modes need a keyword containing only letters.

  2. Enter text and key

    Type or paste the text; the key stream ignores non-letters and preserves case by default.

  3. Analyze a ciphertext

    Read the IoC, pick a candidate period, then edit per-position key letters until the trial plaintext looks right.

  4. Copy the result

    Copy or download the ciphertext, plaintext or analysis report from the output panel.

Use cases

Cryptography coursework

Work through the classic ciphertext → key length → key → plaintext exercise path.

CTF puzzles

Try candidate periods and hand-edit key letters with immediate trial decryption.

Classroom demonstrations

Show how a keyword shifts letters and why polyalphabetic ciphers leak frequency structure.

Modes and conventions

Mode / optionBehavior
EncryptC = (P + K) mod 26, using only A–Z letters
DecryptP = (C − K + 26) mod 26
AnalyzeIoC, period ranking and per-position key guesses
Preserve caseEach output letter matches the source letter's case
Lowercase outputAll output letters are folded to lowercase
Non-lettersSpaces, digits, punctuation and accents pass through unchanged

IoC = Σ nᵢ(nᵢ−1) / (N(N−1)) over the 26 letter counts; N < 2 shows as unavailable.

Common mistakes

Mistake:Treating Vigenère as secure because the key is a word.

Fix:It is a classical cipher with a tiny keyspace and statistical weaknesses; use it for learning, never for secrets.

Mistake:Assuming spaces and punctuation advance the key.

Fix:Only A–Z letters consume a key character; everything else passes through unchanged.

Mistake:Expecting the tool to crack the key end-to-end.

Fix:Suggestions assist; you confirm or edit each key letter and read the trial plaintext yourself.

Mistake:Trusting a period from a short ciphertext.

Fix:Below roughly 30 letters the tool warns that IoC and period ranking are unreliable.

Mistake:Comparing uppercase and lowercase keys as different ciphers.

Fix:Keys are normalized to lowercase internally; only the output casing option changes the result.

Frequently asked questions

How does the Vigenère cipher work?

Each plaintext letter is shifted by the corresponding letter of a repeated keyword: encrypt uses (P + K) mod 26, decrypt uses (C − K + 26) mod 26. The classic example ATTACKATDAWN with key LEMON produces LXFOPVEFRNHR. The key stream advances only on letters.

What is the index of coincidence?

It measures how likely two random letters from a text are equal: Σ nᵢ(nᵢ−1) / (N(N−1)) over the 26 letter counts. English prose scores about 0.0667, random text about 0.0385. A period that splits a Vigenère ciphertext into English-like cosets raises the average IoC.

How do I find the key length?

Use the period buttons in Analysis mode. The tool ranks periods 1–20 by average coset index of coincidence. Pick a candidate, review the per-position key-letter suggestions, and edit them until the trial plaintext reads naturally. Multiples of the true period can also score highly, so compare a few candidates.

What happens to spaces and punctuation?

They pass through untouched and do not advance the key stream. Casing is preserved per source letter by default, with a lowercase-output option. Accented letters such as é are treated as non-alphabetic and left unchanged.

Is Vigenère secure?

No. It is a classical cipher with a small keyspace and visible statistical structure. This tool is for coursework, puzzles and teaching only — never use it to protect real data.

Is my ciphertext uploaded?

No. Encryption, decryption and all analysis run in your browser. The exercise text is never transmitted or stored.

References & standards