自动密钥密码编码器

The Autokey cipher is a self-keying Vigenere variant where the plaintext itself extends the encryption key. Instead of repeating a short keyword, each plaintext letter becomes part of the key for subsequent characters, eliminating the periodic patterns that make standard Vigenere vulnerable to Kasiski examination. Use this free tool to encode and decode Autokey cipher messages instantly with automatic key extension.

Result
0 characters

Settings

Frequently Asked Questions About the Autokey Cipher

What is the Autokey cipher?

The Autokey cipher is a polyalphabetic substitution cipher that uses the plaintext message itself to extend the encryption key. Unlike the standard Vigenere cipher, which repeats a short keyword, the Autokey cipher appends the plaintext to the keyword to create a key that is as long as the message. This eliminates the repeating key pattern that makes Vigenere vulnerable to Kasiski examination.

How does the Autokey cipher extend its key?

The key is extended by appending the plaintext letters after the initial keyword. For example, if the keyword is "KEY" and the plaintext is "HELLO WORLD", the full key becomes "KEYHELLOW". Each plaintext letter, once encrypted, becomes part of the key for subsequent letters. This self-referencing mechanism ensures the key never repeats in a predictable cycle.

How is the Autokey cipher different from Vigenere?

The Autokey cipher differs from Vigenere in how the key is generated. Vigenere repeats a fixed keyword over and over, creating periodic patterns that attackers can exploit through Kasiski examination or index of coincidence analysis. The Autokey cipher eliminates this periodicity by using the plaintext itself to extend the key, producing a non-repeating key stream that resists standard Vigenere attacks.

How do you encrypt with the Autokey cipher?

To encrypt, first write your keyword followed by the plaintext to form the full key. Then, for each plaintext letter, add its position value to the corresponding key letter's position value modulo 26 to get the ciphertext letter. For example, with keyword "KEY" and plaintext "ATTACK", the key becomes "KEYATT". The first letter A (0) plus K (10) gives K (10), and so on for each subsequent letter.

How do you break an Autokey cipher?

Breaking an Autokey cipher requires guessing the keyword length and then testing possible keyword values. Since the key does not repeat, standard Kasiski examination fails. Instead, cryptanalysts try assumed keyword lengths and use the self-referencing property to recover plaintext fragments. If a guessed keyword segment produces readable plaintext, that plaintext extends the known key further, allowing the entire message to be decrypted progressively.

Who invented the Autokey cipher?

The Autokey cipher was first described by Giovan Battista Bellaso in 1553 and later improved by Blaise de Vigenere in his 1586 treatise "Traicte des Chiffres." Vigenere's version used the plaintext itself to extend the key, which was a significant improvement over simply repeating a keyword. Ironically, the simpler repeating-key cipher is commonly called the "Vigenere cipher" today, while Vigenere's actual, more secure invention is known as the Autokey cipher.

Is the Autokey cipher more secure than Vigenere?

Yes, the Autokey cipher is more secure than the standard Vigenere cipher. Because the key does not repeat in a fixed cycle, it is immune to Kasiski examination and index of coincidence attacks that easily break Vigenere. However, the Autokey cipher is still vulnerable to known-plaintext attacks and other advanced cryptanalytic methods. It is not suitable for modern security applications but represents an important historical improvement in polyalphabetic cipher design.

什么是自动密钥密码?

自动密钥密码(Autokey Cipher,有时也搜索为"auto cipher")是一种多表替换密码,解决了标准维吉尼亚密码的最大弱点:重复密钥问题。与其反复循环一个短关键词不同,自动密钥密码使用明文本身来扩展加密密钥,产生一个永远不会以可预测模式重复的密钥流。

这一概念由乔万·巴蒂斯塔·贝拉索(Giovan Battista Bellaso)于 1553 年首次描述,后由布莱兹·德·维吉尼亚(Blaise de Vigenere)在其 1586 年著作《密码论》(Traicte des Chiffres)中进一步完善。具有讽刺意味的是,今天通常被称为"维吉尼亚密码"的是更简单的重复密钥版本,而维吉尼亚真正更安全的发明却被称为自动密钥密码。

自动密钥密码的工作原理

加密过程将一个短种子关键词与明文结合,构建一个不重复的密钥流:

  1. 写下种子关键词作为密钥流的开头
  2. 在种子后追加明文字母以填充剩余的密钥
  3. 加密每个字母:将明文字母的值与对应密钥字母的值相加,模 26

示例演练

使用种子关键词"KEY"和明文"ATTACK":

位置123456
明文ATTACK
密钥流KEYATT
密文KXRAVD

注意密钥流的第 4-6 位如何使用来自第 1-3 位的明文字母 A、T、T。这种自引用机制意味着每条消息都生成一个唯一的、不重复的密钥。

明文自动密钥与密文自动密钥

这种密码有两个历史变体:

  • 明文自动密钥(标准形式):密钥流使用明文字符扩展。这是维吉尼亚的原始设计,也是我们工具默认实现的版本。
  • 密文自动密钥:密钥流改用密文字符扩展。这个变体具有不同的安全特性和错误传播行为。

两者都消除了重复密钥模式,但明文自动密钥在密码学课程中更被广泛研究和讲授。

自动密钥密码与维吉尼亚密码的比较

特性自动密钥密码维吉尼亚密码博福特密码
密钥机制种子 + 明文扩展重复关键词重复关键词(互反)
密钥是否重复?
Kasiski 检验无效有效攻击有效攻击
基于重合指数的密钥长度分析无效有效攻击有效攻击
已知明文攻击的脆弱性高(级联揭示密钥)
字典攻击的脆弱性高(明文在密钥流中)

自动密钥密码的关键优势是对 Kasiski 检验和重合指数分析的免疫性——这是攻击标准维吉尼亚密码的两种主要方法。然而,密钥流中自然语言的存在产生了不同的脆弱性:对密钥流各位置测试常见词汇的字典攻击。

如何使用本工具

  1. 在密钥字段输入种子关键词。即使是短种子(3-6 个字符)也能很好地工作,因为明文会自动扩展它。
  2. 在输入字段输入或粘贴消息。工具会实时显示密钥流的构建过程。
  3. 观察可视化,了解每个明文字母是如何成为后续字符的密钥的一部分。
  4. 使用复制按钮复制结果

用模式选择器在加密和解密之间切换。该工具同时支持明文自动密钥和密文自动密钥变体。

常见问题

自动密钥密码与维吉尼亚密码有什么区别?

维吉尼亚密码在整个消息中重复一个固定的关键词(如"KEYKEYKEYKEY"),产生周期性模式。自动密钥密码使用明文本身来扩展种子密钥(如"KEYATTACK…"),消除了重复。这使自动密钥密码对 Kasiski 检验——攻击维吉尼亚密码的主要方法——具有免疫性。

如何破解自动密钥密码?

由于密钥不重复,标准维吉尼亚密码攻击方法无效。相反,密码分析师使用字典攻击,在密钥流的各个位置测试常见词汇。当一个猜测的词产生可读的明文时,该明文会进一步扩展已知密钥,级联揭示整条消息。我们的自动密钥解码器可自动化这一过程。

自动密钥密码比维吉尼亚密码更安全吗?

是的,针对破解维吉尼亚密码的特定攻击(Kasiski 检验、重合指数分析)而言。然而,自动密钥密码容易受到利用密钥流中自然语言模式的已知明文攻击和字典攻击。两种密码都不适合现代安全应用。

什么样的种子关键词比较好?

选择一个 6-10 个随机字符、避免字典词汇的种子。种子在明文字符接管密钥流之前提供初始保护。较长的种子会略微增加安全性,但并非严格必要,因为自动密钥机制会自动处理扩展。

自动密钥密码实际上是谁发明的?

乔万·巴蒂斯塔·贝拉索于 1553 年首次描述了这一概念。布莱兹·德·维吉尼亚在其 1586 年《密码论》中进一步完善,特别提出明文本身应该扩展密钥。"自动密钥"这个名称(意为"自扩展")反映了这种自我延伸的特性。

相关工具与资源