恩尼格玛密码机模拟器

The Enigma machine was an electromechanical cipher device used by Nazi Germany during World War II to encrypt military communications. With over 158 quintillion possible configurations, it was considered unbreakable until Polish and British codebreakers at Bletchley Park — led by Alan Turing — exploited its structural weaknesses. Use this free simulator with authentic Wehrmacht Enigma I rotors, reflectors, and plugboard to encrypt and decrypt messages.

Machine Configuration

左转子
转子:
位置:
环设置:
中转子
转子:
位置:
环设置:
右转子
转子:
位置:
环设置:
反射板:
Plugboard0/13 pairs
LeftI
Z
A
B
Q
MiddleII
Z
A
B
E
RightIII
Z
A
B
V
加密
结果
0 字符
Type a character to see the signal path

Frequently Asked Questions About the Enigma Machine

What is the Enigma machine?

The Enigma machine was an electromechanical cipher device used primarily by Nazi Germany during World War II to encrypt military communications. Invented by German engineer Arthur Scherbius in 1918 and commercially available from 1923, it was adopted by the German military in 1926. The machine uses a combination of rotors, a reflector, and a plugboard to create an extremely complex substitution cipher. With over 158 quintillion possible settings, it was considered unbreakable — until Polish and British codebreakers found exploitable weaknesses in how operators used it.

How does the Enigma machine work?

When a key is pressed, the signal passes through the plugboard (which swaps some letter pairs), then through three rotors in sequence (each scrambling the alphabet differently), hits a reflector that bounces the signal back through all three rotors in reverse, passes through the plugboard again, and lights up the output lamp. Before each keypress, the rightmost rotor steps forward, and mechanical notches cause the middle and left rotors to step at specific intervals. This means each letter is encrypted with a different substitution alphabet, making frequency analysis nearly impossible.

Who broke the Enigma code?

The Enigma was first broken by Polish mathematician Marian Rejewski in 1932, along with colleagues Jerzy Rozycki and Henryk Zygalski. They shared their work with Britain and France in 1939, just before the war. At Bletchley Park in England, Alan Turing and Gordon Welchman built the Bombe machine in 1940 to automate the process of finding daily Enigma settings. Their work is estimated to have shortened World War II by at least two years, saving millions of lives.

What is double stepping in the Enigma machine?

Double stepping is a mechanical anomaly where the middle rotor advances on two consecutive keypresses. Normally, the middle rotor only steps when the right rotor reaches its notch position. However, if the middle rotor itself is at its notch position, the mechanical pawl engages and causes it to step again when the left rotor advances. This reduces the theoretical period of the machine from 26x25x26 = 16,900 to 26x25x26 = 16,900 minus a small number, and was one of the quirks that codebreakers had to account for.

What does the plugboard do on the Enigma machine?

The plugboard (Steckerbrett) is a panel on the front of the Enigma machine with 26 sockets, one for each letter. Operators could use cables to connect pairs of letters, causing them to swap before and after the rotor encryption. Up to 13 pairs could be connected simultaneously. The plugboard was the single greatest source of the Enigma's cryptographic strength, contributing a factor of over 150 trillion to the total number of possible settings.

How many possible configurations does the Enigma machine have?

The Wehrmacht Enigma I has approximately 158,962,555,217,826,360,000 (roughly 1.59 x 10^20) possible configurations. This comes from: choosing 3 rotors from 5 (60 ways), 26^3 starting positions (17,576), 26^3 ring settings (17,576), and the plugboard connections with 10 pairs (over 150 trillion combinations). Even modern computers would need significant time to brute-force all possibilities, though the machine's known weaknesses make targeted attacks feasible.

Is the Enigma machine secure by modern standards?

No. While the Enigma's key space of ~1.59 x 10^20 seems large, modern computers can search it rapidly. More importantly, the Enigma has fundamental cryptographic weaknesses: a letter can never encrypt to itself (due to the reflector), the substitution is involutory (encrypt = decrypt), and the rotors create patterns that can be exploited. Modern encryption algorithms like AES use key spaces of 2^256 (far larger) and avoid all of these structural weaknesses.

What role did Alan Turing play in breaking Enigma?

Alan Turing joined Bletchley Park's codebreaking efforts in September 1939 and designed the Bombe machine, an electromechanical device that could test thousands of possible Enigma settings per second. Turing exploited the fact that no letter can encrypt to itself (the reflector property) and used known plaintext attacks — guessing likely words in messages (called 'cribs') — to dramatically narrow down possible settings. His work, along with Gordon Welchman's improvements, made it possible to decrypt Enigma messages fast enough to be militarily useful.

What is the Bletchley Park connection to Enigma?

Bletchley Park was a Victorian mansion in Buckinghamshire, England, that served as the headquarters of Britain's Government Code and Cypher School (GC&CS) during World War II. At its peak, over 10,000 people worked there, including mathematicians, linguists, and chess champions. The codebreaking work done at Bletchley Park — particularly on Enigma and the more advanced Lorenz cipher — produced intelligence codenamed 'Ultra,' which gave the Allies advance knowledge of German military plans and is widely credited with helping shorten the war.

什么是恩尼格玛密码机(Enigma Machine)?

恩尼格玛密码机(Enigma machine)是一种机电密码设备,主要由纳粹德国在二战期间用于加密军事通信。该机器由德国工程师 Arthur Scherbius 于 1918 年发明,1923 年开始商业销售,德国军方于 1926 年采用。它结合插接板、三个(或更多)转子和反射器,产生一种多表替换密码,大约有 158 千兆亿种可能配置——以 1940 年代的技术使得暴力破解几乎不可能。

尽管密钥空间巨大,恩尼格玛密码机仍通过数学洞察力、操作员失误和专用机械的结合被破解。波兰数学家 Marian Rejewski 于 1932 年首次破解了恩尼格玛,其工作后来在布莱切利庄园Alan Turing 扩展,后者设计了"炸弹"机器来自动搜索每日设置。他们的集体努力估计使第二次世界大战缩短了至少两年。

恩尼格玛密码机的工作原理

信号路径

当按下恩尼格玛键盘上的一个键时,电信号沿以下路径传输:

  1. 插接板(Steckerbrett) — 信号首先通过插接板,该板交换字母对。最多可连接 13 根电缆,每根交换两个字母。
  2. 入口轮(Eintrittswalze) — 信号通过静态入口轮进入转子组件。
  3. 右侧转子 — 信号通过最右侧转子,根据其内部连线和当前位置替换字母。
  4. 中间转子 — 信号继续通过中间转子。
  5. 左侧转子 — 信号通过最左侧转子。
  6. 反射器(Umkehrwalze) — 反射器将信号反向通过各转子,确保没有字母能加密为其自身。
  7. 转子(反向) — 信号从左到右反向穿过全部三个转子,使用逆向连线路径。
  8. 插接板(再次) — 信号在点亮输出灯之前再次通过插接板。

转子步进机制

每个字母加密前,转子向前步进:

  • 右侧转子每次按键前进一个位置。
  • 中间转子在右侧转子到达其缺口位置(由转子类型决定的特定字母)时前进。
  • 左侧转子在中间转子到达其缺口位置时前进。

这产生了双重步进异常:如果中间转子正处于自身的缺口位置,当左侧转子前进时它会再次步进,导致在连续两次按键中都移动。这一机械怪癖略微缩短了密码的周期,是破译者的重要切入点。

转子

国防军恩尼格玛 I 型使用五个可互换的转子(标记为 I 至 V),每个转子有不同的内部连线和一个缺口位置:

转子缺口进位
IQR
IIEF
IIIVW
IVJK
VZA

从五个转子中选择三个以任意顺序放置,共有 60 种可能的转子排列。

环设置

每个转子有从 1 到 26 的环设置(Ringstellung),用于偏移转子内部连线与其可见位置指示器之间的关系。环设置在不改变连线本身的情况下,改变转子位置与其内部连线之间的映射关系。

反射器

反射器(Umkehrwalze)将全部 26 个字母两两配对,将信号反向通过转子。共使用了三种反射器:

  • UKW-A — 用于早期型号
  • UKW-B — 战争期间最常用的反射器
  • UKW-C — 备选反射器

反射器使恩尼格玛具有互反性(或对合性):用相同设置加密一条消息会产生原始明文。这意味着加密和解密是同一种操作

插接板

插接板(Steckerbrett)是恩尼格玛密码强度的最大单项贡献者。使用 10 对电缆(标准操作配置),仅插接板就提供超过 150 万亿种可能配置。每根电缆在转子加密前后分别交换一对字母。

恩尼格玛的历史与破解

波兰破译者(1932-1939)

1932 年,波兰密码局的数学家 Marian Rejewski 利用一个程序性弱点——操作员在每条消息开头将每日消息密钥加密两次。利用这种冗余和数学群论,Rejewski 在未曾见过实物机器的情况下重建了转子连线。

他与同事 Jerzy RozyckiHenryk Zygalski 一起建造了**炸弹(Bomba)**机器并创建了 Zygalski 图表来寻找每日设置。1939 年 7 月,就在德国入侵波兰前几周,他们将完整知识分享给了英国和法国情报部门。

布莱切利庄园(1939-1945)

在布莱切利庄园,Alan Turing 设计了一种改进的"炸弹"机器,利用不同的弱点:已知明文(称为"已知词")。操作员经常以可预测的短语开头消息,如天气报告或"无可报告"(NIHIL NOVI)。结合没有字母能加密为自身的反射器特性,已知词大幅缩小了搜索空间。

Gordon Welchman 通过"对角板"改进了 Turing 的设计,利用了插接板的对称性。鼎盛时期,超过 200 台炸弹机器在布莱切利庄园及其分站同时运行,每秒处理数千种可能设置。

解密恩尼格玛消息产生的情报,代号为 Ultra,使盟军提前知晓德国军事计划,被普遍认为使战争缩短了两年或更长时间。

恩尼格玛的主要弱点

尽管密钥空间巨大,恩尼格玛仍有几个可利用的弱点:

  1. 无自加密 — 一个字母永远不能加密为其自身(由于反射器)。这是 Turing 的主要利用点。
  2. 互反加密 — 相同设置既加密又解密,限制了密码的数学结构。
  3. 操作员失误 — 重复消息密钥、可预测的已知词,以及懒惰的操作员重复使用设置。
  4. 转子顺序规律 — 机械步进在连续字母之间产生可预测的数学关系。

恩尼格玛与现代加密的比较

特征恩尼格玛AES-256
密钥空间~1.59 x 10^202^256 (~1.16 x 10^77)
自加密不可能可能
已知明文抵抗力
算法保密性必须保密不需要(Kerckhoffs 原则)

现代加密算法避免了恩尼格玛所有的结构性弱点,同时在难以想象的更大密钥空间上运行。然而,恩尼格玛在密码学史上仍是一个里程碑式的成就,也是理解密码机制的极佳教育工具。