维吉尼亚密码 — 在线解码器和编码器

The Vigenère cipher is a polyalphabetic substitution cipher that uses a keyword to apply different Caesar shifts to each letter. Once called "le chiffre indéchiffrable" (the undecipherable cipher), it can now be decoded using Kasiski examination and frequency analysis. Use this free Vigenère cipher decoder and encoder to encrypt, decrypt, and automatically solve Vigenère-encrypted messages.

"HELLO""RIJVS"(Key: KEY)
结果
0 字符
None

Settings

Character Set

All processing happens in your browser — no data is sent to any server

Vigenère Tabula Recta (Preview)

The tabula recta is the 26×26 grid used for Vigenère encryption. Find the row matching the key letter and the column matching the plaintext letter — the intersection is the ciphertext letter.

ABCDEF
AABCDEF
BBCDEFG
CCDEFGH
DDEFGHI
EEFGHIJ
FFGHIJK

Showing 6×6 preview of the full 26×26 Vigenère table

Frequently Asked Questions About Vigenere Cipher

What is the Vigenere cipher and how does it work?

The Vigenere cipher is a polyalphabetic substitution cipher invented by Blaise de Vigenere in the 16th century. It uses a keyword where each letter determines a different shift value (A=0, B=1, C=2, etc.). The keyword repeats to match the length of the plaintext, and each plaintext letter is shifted by the amount indicated by the corresponding keyword letter. For example, with keyword 'KEY', the first letter shifts by 10 (K), the second by 4 (E), the third by 24 (Y), then the pattern repeats.

How do you break a Vigenere cipher?

Breaking a Vigenere cipher involves two steps: first, determine the keyword length using the Kasiski examination (finding repeated sequences) or the Index of Coincidence method; second, once the key length is known, treat each position as a separate Caesar cipher and use frequency analysis on each group of letters. Our auto-solver tool performs these steps automatically.

What is a tabula recta in Vigenere cipher?

The tabula recta (also called a Vigenere table or Vigenere square) is a 26×26 grid of alphabets, where each row is shifted one position to the left compared to the row above. To encrypt a letter, find the row corresponding to the keyword letter and the column corresponding to the plaintext letter — the intersection gives the ciphertext letter. Our tool includes an interactive tabula recta visualization.

Why was the Vigenere cipher called "le chiffre indéchiffrable"?

The Vigenere cipher was called "le chiffre indéchiffrable" (the indecipherable cipher) because it resisted all attempts at cryptanalysis for over 300 years after its invention. Its polyalphabetic nature defeated the frequency analysis techniques that could easily break monoalphabetic ciphers like the Caesar cipher. It was not broken until Charles Babbage and Friedrich Kasiski independently developed methods in the mid-19th century.

What is the difference between Vigenere and Caesar cipher?

The Caesar cipher is a monoalphabetic cipher that shifts every letter by the same fixed amount, making it vulnerable to frequency analysis. The Vigenere cipher is polyalphabetic, using a keyword to apply different shift values to different positions in the text. This means the same plaintext letter can encrypt to different ciphertext letters depending on its position, making frequency analysis much more difficult.

How do you choose a good Vigenere cipher key?

A strong Vigenere cipher key should be long, random, and avoid dictionary words or repeating patterns. Longer keys increase the number of distinct Caesar shifts applied, making frequency analysis harder. Ideally, the key should be at least as long as the plaintext — when the key is truly random and equal in length to the message, the Vigenere cipher becomes a one-time pad, which is theoretically unbreakable.

Is the Vigenere cipher still secure today?

No, the Vigenere cipher is not secure for modern use. It can be broken using the Kasiski examination and frequency analysis techniques developed in the 1800s. Modern computers can break it almost instantly. However, the Vigenere cipher remains an important educational tool for understanding polyalphabetic encryption and the foundations of modern cryptography.

Who actually invented the Vigenere cipher?

Despite its name, the Vigenere cipher was first described by Giovan Battista Bellaso in his 1553 booklet "La cifra del. Sig. Giovan Battista Bellaso." Blaise de Vigenère later published a stronger autokey variant in 1586, but over the centuries historians incorrectly attributed Bellaso's simpler cipher to Vigenère. This misattribution became so entrenched that the name stuck. The historical confusion was not widely corrected until David Kahn's 1967 book "The Codebreakers" clarified the distinction between the two systems.

What does polyalphabetic mean in cryptography?

Polyalphabetic means "using multiple alphabets." In a polyalphabetic cipher like Vigenere, each letter in the plaintext can be encrypted using a different substitution alphabet, depending on its position and the keyword. This contrasts with monoalphabetic ciphers (like Caesar) that use a single fixed alphabet for every letter. The advantage of polyalphabetic encryption is that the same plaintext letter can produce different ciphertext letters at different positions, which defeats simple frequency analysis. For example, in Vigenere with keyword "KEY", the letter 'A' at position 1 encrypts as 'K', but 'A' at position 2 encrypts as 'E'.

How to decode Vigenère cipher without the key?

To decode a Vigenère cipher without the key, use a two-step process. First, determine the key length using Kasiski examination (finding repeated sequences in the ciphertext and calculating the GCD of their distances) or the Index of Coincidence method. Second, once you know the key length, split the ciphertext into groups and apply frequency analysis to each group as if it were a separate Caesar cipher. Our auto-solver performs these steps automatically — just paste your ciphertext and click solve.

What is the Vigenère cipher table (tabula recta) used for?

The Vigenère cipher table, also called the tabula recta or Vigenère square, is a 26×26 grid where each row is a Caesar-shifted alphabet. To encrypt: find the row matching the keyword letter and the column matching the plaintext letter — their intersection is the ciphertext letter. To decrypt: find the row matching the keyword letter, then locate the ciphertext letter in that row — the column header is the plaintext letter. Our interactive table lets you trace encryption paths visually.

How is Vigenère cipher different from a one-time pad?

The Vigenère cipher and the one-time pad use the same encryption algorithm, but differ in key management. Vigenère uses a short keyword that repeats, creating patterns that can be exploited by Kasiski examination and frequency analysis. A one-time pad uses a truly random key at least as long as the message, never reused — making it theoretically unbreakable. The Vigenère cipher is essentially a one-time pad with a repeating key, and that repetition is its fundamental weakness.

什么是维吉尼亚密码(Vigenère Cipher)?

维吉尼亚密码是一种多表替换密码,通过根据重复关键字对每个字母应用不同的凯撒位移来加密文本。若关键字为"KEY",则第一个字母位移 10(K = 10),第二个字母位移 4(E = 4),第三个字母位移 24(Y = 24),然后模式循环重复。这意味着同一个明文字母可以根据其位置加密为不同的密文字母——这正是多表替换密码区别于凯撒密码等单表替换密码的决定性特征。

在超过 300 年的时间里,从 1553 年发明到 1863 年首次公开密码分析,维吉尼亚密码被称为 "le chiffre indéchiffrable"——无法破解的密码。它通过平坦化字母频率分布,击败了那个时代所有已知的攻击方式,而正是字母频率分布使单表密码轻而易举地被破解。直到 Friedrich Kasiski 和独立研究的 Charles Babbage 开发出新的统计技术,这个密码才最终被攻破。

维吉尼亚密码的工作原理

加密公式

对于位置 i 处的每个明文字母,加密公式为:

Cᵢ = (Pᵢ + Kᵢ) mod 26

其中 Pᵢ 是明文字母的位置(A = 0,B = 1,… Z = 25),Kᵢ 是对应关键字字母的位置,mod 26 将结果限制在字母表范围内。

解密公式

Pᵢ = (Cᵢ − Kᵢ + 26) mod 26

逐步示例

用关键字 LEMON 加密 ATTACK AT DAWN

位置明文关键字字母P + Kmod 26密文
1A (0)L (11)1111L
2T (19)E (4)2323X
3T (19)M (12)315F
4A (0)O (14)1414O
5C (2)N (13)1515P
6K (10)L (11)2121V
7A (0)E (4)44E
8T (19)M (12)315F
9D (3)O (14)1717R
10A (0)N (13)1313N
11W (22)L (11)337H
12N (13)E (4)1717R

结果: ATTACK AT DAWN → LXFOPV EF RNHR

注意,位置 2 和 3 的两个 T 加密为不同的字母(X 和 F),因为它们与不同的关键字字母(E 和 M)对应。类似地,位置 1、4、7 的三个 A 分别变为 L、O 和 E。这种变化的替换正是频率分析对多表替换密码无效的原因所在。

维吉尼亚方阵(Tabula Recta)

维吉尼亚方阵(又称 Vigenère 方阵或 Vigenère 表格)是一个 26×26 的字母网格,是手动执行维吉尼亚加密的传统查找工具。每行代表一种不同位移量的凯撒密码——第 A 行为位移 0,第 B 行为位移 1,依此类推。

使用维吉尼亚方阵加密字母的步骤:

  1. 找到与关键字字母对应的
  2. 找到与明文字母对应的
  3. 行列交叉处的字母即为密文字母。

本页预览表显示了完整网格的 6×6 部分。请在我们的互动维吉尼亚表格页面浏览完整的 26×26 维吉尼亚方阵,在那里您可以点击任意单元格查看加密关系。

如何识别维吉尼亚密文

在尝试破解密码之前,判断是否面对维吉尼亚加密很有帮助。以下几个特征可将维吉尼亚密文与其他密码类型区分开来:

  • 仅含字母,单词边界保留。 与凯撒密码一样,维吉尼亚密码传统上仅加密字母字符,保留空格和标点符号不变。单词长度与原始明文相同。
  • 频率分布平坦但不均匀。 凯撒密码中,频率分布看起来像英语但发生了位移。而在维吉尼亚密文中,分布明显更加平坦——没有单个字母占主导地位——但也不是完全均匀的(完全均匀可能表明使用了一次性密码本或随机文本)。
  • 重合指数介于 0.04 到 0.05 之间。 维吉尼亚密文的重合指数(IC)通常落在英语值(约 0.067)和随机值(约 0.038)之间,具体取决于密钥长度。处于这一中间范围的 IC 是多表替换的有力指示。
  • 等间隔出现重复序列。 如果发现相同的 3 个及以上字母序列以共享公因数的间距出现,则文本很可能是维吉尼亚加密的(这是 Kasiski 分析法的基础)。

本站的密码识别器工具利用这些特征自动检测维吉尼亚加密并估计密钥长度。

维吉尼亚密码的现代应用场景

尽管已有数百年历史,维吉尼亚密码在现代语境中仍频繁出现:

  • CTF 竞赛。 网络安全夺旗(CTF)挑战中,维吉尼亚加密常在中等难度关卡中出现。参赛者需要识别密码类型、确定密钥长度并恢复密钥以获取标志。
  • 密室逃脱与谜题游戏。 维吉尼亚密码是多步骤谜题的热门选择,因为它同时需要密钥和密文,让谜题设计者可以将关键字藏在另一个单独线索中。
  • 密码学课程。 维吉尼亚密码是大学密码学和信息安全课程中教授多表替换、密钥管理、Kasiski 分析和重合指数的标准示例。
  • 流行文化。 维吉尼亚密码出现在电视剧《神秘小镇》(Gravity Falls)、视频游戏《命运 2》(Destiny 2)以及众多侦探小说中。动画《神秘小镇》曾在片尾字幕中使用维吉尼亚加密消息,关键字隐藏在每集剧情中。
  • 历史重现。 内战爱好者和教育项目使用复制品同盟密码盘来演示符合时代特征的加密技术。

相关多表替换密码

维吉尼亚密码属于一个从同一核心思想演化而来的多表替换密码家族:

  • 博福特密码 — 一种互逆变体,关键字字母从固定位置相减而非相加。博福特密码的加密和解密使用相同操作。
  • 自动密钥密码 — Vigenère 本人的发明:密钥以一个引导字开头,然后将明文本身追加为密钥,消除了重复密钥的弱点。
  • 格伦斯菲尔德密码 — 维吉尼亚密码的一个变体,将密钥限制为数字(0–9),将每个位置的密钥空间从 26 缩减到 10。
  • 流水密钥密码 — 使用一段长文本(如书中某页)作为密钥,在不需要真正随机密钥的情况下接近一次性密码本的安全性。
  • 特里塞缪斯密码 — 其前身,无秘密密钥地对每个字母依次位移(A=0,B=1,C=2,……)。Bellaso 的创新是将这种固定递进改为秘密关键字。
  • 波尔塔密码 — 一种使用 13 个字母表的互逆双字母密码,设计为自逆系统。
  • 泥淖密码 — 由四种变体组成的密码家族,将关键字混合字母表与维吉尼亚风格的多表位移相结合。
  • 阿尔贝蒂密码 — 第一种多表替换密码,由 Leon Battista Alberti 于 1460 年代发明,使用旋转密码盘。Alberti 在加密过程中更换字母表的概念是所有后续多表替换系统(包括 Bellaso 的关键字方法)的先驱。

从 Alberti 密码盘(1460 年代)→ 特里塞缪斯的递进位移(1508 年)→ Bellaso 的关键字方法(1553 年)→ Vigenère 的自动密钥系统(1586 年)的演进,代表了密码学史上最重要的发展脉络之一,每一步都针对前一设计的弱点做出了改进。

延伸阅读

探索维吉尼亚密码的历史、密码分析技术和代码实现: