博福特密码

The Beaufort cipher is a reciprocal polyalphabetic cipher where encryption and decryption use the same operation. Created by Admiral Sir Francis Beaufort, it applies the formula C = (K - P) mod 26 with a repeating keyword, meaning encoding ciphertext with the same key instantly recovers the original plaintext. Use this free online tool to encrypt and decrypt Beaufort cipher messages with any keyword.

自互反- 加密和解密使用相同操作
结果
0 字符
Moderate

Acceptable security for casual use

Frequently Asked Questions About Beaufort Cipher

What is the Beaufort cipher?

A polyalphabetic substitution cipher that is self-reciprocal. The Beaufort cipher was created by Admiral Sir Francis Beaufort as a variant of the Vigenere cipher. Its defining feature is that the same algorithm performs both encryption and decryption using the formula C = (K - P) mod 26. This eliminates the need for separate encode and decode procedures, simplifying field use in naval communications.

How does the Beaufort cipher differ from Vigenere?

Beaufort subtracts plaintext from the key instead of adding. Vigenere encrypts with C = (P + K) mod 26 and decrypts with P = (C - K) mod 26, requiring two distinct operations. Beaufort uses C = (K - P) mod 26 for both encryption and decryption, making it self-reciprocal. This reversal produces different ciphertext from the same plaintext and key, and creates a mirrored tabula recta.

Why is the Beaufort cipher called reciprocal?

Because encrypting ciphertext again recovers the plaintext. When you apply the Beaufort cipher operation to already-encrypted text using the same keyword, you get back the original message. Mathematically, applying C = (K - P) mod 26 twice is an identity operation. This means there is no separate decryption step — the single algorithm reverses itself automatically.

Who invented the Beaufort cipher?

Admiral Sir Francis Beaufort (1774-1857), a Royal Navy officer. Beaufort was a British hydrographer best known for the Beaufort wind force scale used in meteorology. He developed this cipher for secure naval communications during his service. He also served as Hydrographer of the Navy and contributed significantly to maritime navigation and cartographic surveying.

How do you encrypt with the Beaufort cipher?

Subtract each plaintext letter from the corresponding key letter mod 26. First, choose a keyword and repeat it to match the message length. For each position, convert both letters to numbers (A=0, B=1, ... Z=25), compute (key - plaintext) mod 26, and convert back to a letter. For example, with key letter K(10) and plaintext H(7): (10 - 7) mod 26 = 3 = D.

Is the Beaufort cipher secure?

No, it is vulnerable to the same attacks as the Vigenere cipher. Kasiski examination can determine the keyword length by finding repeated ciphertext sequences. Once the key length is known, frequency analysis on each column reveals individual key letters. Modern computers can automate this process in seconds. The Beaufort cipher should only be used for education or casual puzzles, never for securing sensitive data.

What is the Beaufort cipher formula?

The formula is C = (K - P) mod 26 for both encryption and decryption. C represents the ciphertext letter, K is the key letter, and P is the plaintext letter, all converted to numbers 0-25. This single formula handles both directions because subtracting from the key is its own inverse operation. In contrast, Vigenere requires two formulas: C = (P + K) mod 26 to encrypt and P = (C - K) mod 26 to decrypt.

什么是博福特密码?

博福特密码(Beaufort Cipher)是由海军上将弗朗西斯·博福特爵士(1774-1857)创造的多表替换密码,他是皇家海军军官,以博福特风力等级而闻名。与大多数古典密码不同,它具有自反性——相同的操作同时执行加密和解密,使其在野战通信中具有独特的实用价值。

博福特密码与维吉尼亚密码密切相关,但有一个关键区别:博福特密码从密钥中减去明文,而非将明文加上密钥。这种反转产生了一种自逆变换,消除了对独立编解码程序的需求。

博福特密码公式

核心公式简单直接:

加密与解密: C = (K - P) mod 26

其中:

  • P 是明文字母值(A=0,B=1,……,Z=25)
  • K 是密钥字母值
  • C 是密文字母值

由于 (K - (K - P)) mod 26 = P,用相同密钥对公式应用两次可以恢复原始消息。这种数学对称性正是密码自反性的来源。

如何使用本博福特密码工具

  1. 输入消息
  2. 选择关键词,它将在消息长度上重复
  3. 实时查看结果——加密即时进行
  4. 一键复制输出

要解密,只需用相同的密钥将密文输入同一工具。自反性意味着无需独立的解码器,尽管我们专用的博福特密码解码器提供了额外的分析功能(如置信度评分)。

博福特密码与维吉尼亚密码的比较

两种密码共享相同的表格结构(tabula recta),但遍历方式不同:

特性博福特密码维吉尼亚密码
加密公式C = (K - P) mod 26C = (P + K) mod 26
解密公式P = (K - C) mod 26(与加密相同)P = (C - K) mod 26
自反性
是否需要独立解密程序不需要需要
tabula recta 遍历列到行行到列
命名来源弗朗西斯·博福特爵士布莱兹·德·维吉尼亚

两种密码都容易受到相同的密码分析攻击——Kasiski 检验和频率分析——因为它们共享相同的底层多表替换结构。

数学基础

自反性来源于直接的代数恒等式。若 C = (K - P) mod 26,则对 C 应用相同操作得到:

(K - C) mod 26 = (K - (K - P)) mod 26 = P

这意味着加密是其自身的逆运算。相比之下,维吉尼亚密码加密时需要加法,解密时需要减法——两种不同的操作。

博福特密码也可以通过其与变体博福特密码的关系来理解,后者使用 C = (P - K) mod 26。标准博福特密码保持自反性,而变体则不具备此特性。

博福特密码的历史

弗朗西斯·博福特海军上将爵士从 1829 年到 1855 年担任皇家海军水文学家。虽然他最出名的是创建了今天气象学中仍在使用的博福特风力等级,但他也为安全海军通信开发了这种密码。

在军事环境中,这种密码因为操作员只需学习一种程序而具有实用价值。在电子加密出现之前的时代,这种简洁性减少了野战中的错误。波尔塔密码具有类似的自反性,表明 19 世纪的密码学家在安全性之外也重视操作简便性。

安全性分析

按现代标准,博福特密码不安全。它与维吉尼亚密码共享所有漏洞:

  • Kasiski 检验通过寻找重复密文序列揭示密钥长度
  • 频率分析(在已知密钥长度后对每列进行)暴露各个密钥字母
  • 重合指数提供统计方法确定密钥长度
  • 现代计算机可在数秒内自动化完成整个攻击过程

这种密码只应用于教育、谜题或历史研究——绝不用于保护敏感数据。

常见问题

如何用博福特密码加密?

将每个明文字母从对应的密钥字母中减去(模 26)。选择一个关键词并重复以匹配消息长度。对每个位置,将两个字母转换为数字(A=0 到 Z=25),计算(密钥 - 明文)mod 26,然后转换回字母。例如,密钥字母 K(10)和明文 H(7):(10 - 7) mod 26 = 3 = D。

为什么叫互反密码?

因为用相同的密钥加密密文可以恢复明文。两次应用 C = (K - P) mod 26 是一个恒等操作——密码在没有独立解密算法的情况下自我逆转。

博福特密码与变体博福特有何不同?

标准博福特使用 C = (K - P) mod 26,具有自反性。变体博福特使用 C = (P - K) mod 26,不具备自反性,需要不同的解密公式,其行为更像反向维吉尼亚密码。

博福特密码能被自动破解吗?

是的。破解维吉尼亚密码的相同技术——Kasiski 检验、频率分析和重合指数——对博福特密码同样有效。有了足够的密文,自动化工具可以确定密钥长度和密钥本身。

相关工具与资源