Vigenère Cipher Encoder & Decoder

Encrypt or decrypt text using the classical Vigenère cipher. Supports custom alphabets, flexible key handling, and step‑by‑step explanation of the cipher.

Use letters from the alphabet below. Empty key is not allowed.

Default: 26 English letters. You can include digits or other symbols to create a custom alphabet.

How the Vigenère cipher works

The Vigenère cipher is a polyalphabetic substitution cipher. Instead of using a single Caesar shift for the whole message, it uses a repeating keyword to choose a different shift for each letter.

Mathematical definition

Assume an alphabet of size \(n\) (for English letters, \(n = 26\)). Map each letter to a number:

  • \(A \rightarrow 0, B \rightarrow 1, \dots, Z \rightarrow 25\)

Let \(P_i\) be the \(i\)-th plaintext letter, \(K_i\) the corresponding key letter, and \(C_i\) the ciphertext letter.

Encryption (plaintext → ciphertext):

\( C_i = (P_i + K_i) \bmod n \)

Decryption (ciphertext → plaintext):

\( P_i = (C_i - K_i) \bmod n \)

The keyword is repeated (or truncated) so that there is one key letter for each plaintext letter (depending on how you handle spaces and punctuation).

Worked example

Encrypt the message ATTACKATDAWN with the key LEMON using the standard A–Z alphabet.

Position Plain Key P K (P+K) mod 26 Cipher
1 A L 0 11 11 L
2 T E 19 4 23 X
3 T M 19 12 5 F
4 A O 0 14 14 O
5 C N 2 13 15 P
6 K L 10 11 21 V
7 A E 0 4 4 E
8 T M 19 12 5 F
9 D O 3 14 17 R
10 A N 0 13 13 N
11 W L 22 11 7 H
12 N E 13 4 17 R

The final ciphertext is LXFOPVEFRNHR.

Options in this Vigenère cipher tool

  • Custom alphabet – extend beyond A–Z to include digits or symbols.
  • Case handling – preserve original case, or force upper/lowercase.
  • Non‑alphabet characters – keep or remove spaces, punctuation, emojis, etc.
  • Key alignment – classical behavior (skip non‑alphabet characters) or advance the key on every character.
  • Step‑by‑step table – see the numeric shifts used for each character.

Limitations and security notes

  • The Vigenère cipher is not secure for real‑world confidentiality.
  • It can be broken using Kasiski examination or Friedman test to guess the key length, followed by frequency analysis.
  • Use it for education, puzzles, or games, not for protecting sensitive data.

Frequently asked questions

What happens if my key contains characters not in the alphabet?

Those key characters are ignored when building the effective key stream. If all characters in the key are invalid, the tool will show an error and refuse to run.

Can I use this for languages other than English?

Yes, as long as you define an appropriate alphabet in the Alphabet field. For example, you can include accented letters or a Cyrillic alphabet. The cipher itself is agnostic to language; it just works on positions in your custom alphabet.

Why does the output sometimes keep spaces and punctuation?

By default, non‑alphabet characters are copied unchanged and do not consume key characters (classical Vigenère behavior). You can change this in the options if you want the key to advance on every character or to strip non‑alphabet characters entirely.