同音替换密码在线编码器

同音替换密码将每个字母映射到多个可能的符号,比简单替换密码更难进行频率分析。使用此免费工具通过自定义替换表编码和解码消息,探索符号分配的工作原理,并了解这种技术为何能抵抗密码分析数个世纪。

加密0 字符
结果
0 字符
符号集:
两位数(00-99)带圈数字
保留空格

按频率排列的符号映射

E12.7%
407000793637918492
T9.06%
03871622661318
A8.17%
530852111906
O7.51%
543273055543
I6.97%
2674829421
N6.75%
5104563985
S6.33%
9023493531
H6.09%
0161867728
R5.99%
4664627134
D4.25%
95508115
L4.03%
45029920
C2.78%
476772
U2.76%
412757
M2.41%
835969
W2.36%
0789
F2.23%
1065
G2.02%
8078
Y1.97%
0938
P1.93%
6833
B1.29%
6048
V0.98%
9614
K0.77%
58
J0.15%
44
X0.15%
30
Q0.1%
63
Z0.07%
42

安全特性

优势

  • 抵抗基本频率分析攻击
  • 每个字母多个符号遮蔽规律
  • 随机化防止相同明文规律

弱点

  • 仍然容易受到高级统计分析
  • 需要安全分发符号映射
  • 无法抵抗现代计算密码分析

Frequently Asked Questions About Homophonic Cipher

What is a Homophonic substitution cipher?

A Homophonic substitution cipher is an encryption method where each plaintext letter can be replaced by one of several possible ciphertext symbols. The number of symbols assigned to each letter is proportional to its frequency in the language, so common letters like E may have 12 symbols while rare letters like Z have just 1. This many-to-one mapping makes the cipher significantly harder to break than a simple substitution cipher.

How does the Homophonic cipher defeat frequency analysis?

It defeats frequency analysis by distributing each letter's occurrences across multiple ciphertext symbols. In a simple substitution cipher, the most common ciphertext symbol reveals the most common plaintext letter. A Homophonic cipher flattens this distribution by giving high-frequency letters like E, T, and A more symbol choices, so no single symbol stands out in a frequency count. This forces attackers to use more advanced statistical techniques instead of basic letter counting.

How do you create a Homophonic cipher key?

You create a Homophonic cipher key by building a substitution table that assigns multiple unique symbols to each letter. First, determine the relative frequency of each letter in your language. Then allocate symbols proportionally — for English, E might get 12 out of 100 total symbols, while Q gets 1. Each symbol must map to exactly one letter, but each letter maps to many symbols. The sender randomly picks among the available symbols for each letter during encryption.

How do you decrypt a Homophonic cipher?

With the key, decryption is straightforward: look up each ciphertext symbol in the substitution table to find its plaintext letter. Without the key, decryption requires advanced cryptanalysis. Attackers typically look for patterns in digraphs and trigraphs, use hill-climbing algorithms to test possible key mappings, and exploit known-plaintext cribs. Large amounts of ciphertext make the task easier because statistical patterns eventually emerge despite the flattened frequency distribution.

What is the Zodiac Killer cipher?

The Zodiac Killer cipher refers to a series of encrypted messages sent by an unidentified serial killer in Northern California during 1969-1970. The most famous, the Z408, was a 408-symbol Homophonic substitution cipher cracked by amateur codebreakers within a week. The Z340 cipher, a harder 340-symbol message, remained unsolved for 51 years until a team of codebreakers deciphered it in 2020 using specialized software and pattern recognition techniques.

How is Homophonic different from simple substitution?

The key difference is the number of symbols per letter. Simple substitution uses a one-to-one mapping where each letter always becomes the same ciphertext character, preserving frequency patterns. Homophonic substitution uses a one-to-many mapping where each letter can become any of several symbols, chosen randomly during encryption. This means identical plaintext letters produce different ciphertext symbols each time, eliminating the frequency signature that makes simple substitution easy to crack.

Is the Homophonic cipher secure?

The Homophonic cipher is significantly more secure than simple substitution but is not considered secure by modern standards. It resists basic frequency analysis, but advanced techniques like hill-climbing algorithms, digraph analysis, and computer-aided brute force can break it with enough ciphertext. Historically it provided strong protection — the Great Cipher of Louis XIV went unbroken for 200 years. For modern security, use contemporary algorithms like AES or RSA instead.

什么是同音替换密码(Homophonic Substitution Cipher)?

同音替换密码(Homophonic Substitution Cipher,也称同音密码)是一种加密方法,其中明文中的每个字母可以被多个可能的符号之一替换。与简单替换密码(一个字母始终映射到一个符号)不同,同音密码根据字母在语言中的出现频率为每个字母分配多个符号

这样做的结果是密文中的频率分布趋于平坦,使标准频率分析的效果大打折扣。常见字母如 E(在英文中频率为 12.7%)会被分配很多符号,而罕见字母如 Z(频率为 0.07%)只分配一两个。加密时,编码者每次遇到某个字母都会从该字母对应的可用符号中随机选取,因此同一明文两次加密会产生不同的密文。

这种方法代表了古典密码学的重大飞跃。从 15 世纪到 19 世纪,它被广泛用于外交和军事通信,并因出现在美国历史上最臭名昭著的悬案之一而声名大噪。

如何抵御频率分析

简单替换密码中,如果 'E' 总是变成 '@',那么 '@' 的出现频率约为 12.7%——立刻就会暴露哪个符号代表最常见的字母。同音密码消除了这个弱点。

字母英文频率分配符号数每个符号的频率
E12.7%12-13 个符号每个约 1%
T9.1%9-10 个符号每个约 1%
A8.2%8-9 个符号每个约 1%
Z0.07%1 个符号约 0.07%
Q0.10%1 个符号约 0.10%

示例: 加密 "MEET" 可能产生:

  • M -> 47
  • E -> 23(从 12 个选项中随机选取)
  • E -> 89(这次选取了不同的符号)
  • T -> 15

字母 E 出现了两次,但每次使用不同的符号,打破了简单替换密码中会暴露规律的频率模式。

当有 100 个或更多适当分配的符号时,密文可以达到近乎平坦的频率分布,迫使密码分析人员依赖更高级的技术,如二元组分析和爬山算法。

佐迪亚克杀手密码

同音替换密码在现代最著名的应用涉及佐迪亚克杀手(Zodiac Killer)——一名在 1968 至 1969 年间活跃于加利福尼亚州北部的身份不明连环杀手。佐迪亚克向湾区报纸发送了四封加密信件,挑战当局揭开他的身份。

Z408——一周内破解

第一封密码信含有 408 个符号,使用了大约 54 个唯一符号的同音替换。业余密码破译者 Donald 和 Bettye Harden 通过识别重复的符号模式和测试可能的单词,在 1969 年 8 月公开发布后不到一周就将其破解。解密后的信息描述了杀手的动机,但未透露其身份。

Z340——悬疑 51 年

第二封主要密码信含有 340 个符号,难度远超第一封。它抵抗了所有密码分析尝试长达半个多世纪,直到 2020 年 12 月,David Oranchak、Jarl Van Eycke 和 Sam Blake 才将其破解,所用方法包括:

  • 计算机爬山算法
  • 发现密码在同音替换之上叠加了换位层
  • 对解密假设进行大规模并行测试

佐迪亚克密码既展示了同音替换的优势,也揭示了其局限性。Z408 被迅速破解,因为它拥有足够的文本量,且使用了相对简单的同音替换。而 Z340 历时 51 年才被破解,因为它将同音替换与额外的换位步骤相结合。

历史应用:路易十四的大密码

历史上最成功的同音密码是大密码(Grande Chiffre),由 Antoine 和 Bonaventure Rossignol 父子于 1626 年为法国宫廷创建:

  • 使用了 600 多个符号,远超普通密码
  • 将同音字母替换与**命名符(nomenclators,代表整个单词和名称的代码符号)**相结合
  • 包含空符号——随机插入的无意义字符作为诱饵
  • 保持超过 200 年未被破解

法国密码分析家 Etienne Bazeries 于 1890 年最终破解了它,方法是识别可能代表常见法语词汇(如"les ennemis",即"敌人")的重复符号序列。解密后的通信揭示了太阳王宫廷的政治阴谋细节,包括与著名的铁面人之谜相关的信息。

如何创建强大的同音密钥

构建有效的密钥需要在符号分配和字母频率之间取得平衡:

  1. 确定符号池——100 个符号是实用的最低限度;200 个以上更为安全
  2. 按比例分配——根据目标语言中每个字母的频率分配符号数量
  3. 确保唯一性——每个符号必须恰好映射到一个字母(不得重叠)
  4. 随机选择——加密时,从每个字母的可用符号中随机选取

提示: 同音密码的密钥材料是完整的符号到字母映射表。发送方和接收方必须拥有相同的副本,且表格必须保密。

同音密码与其他替换方法的比较

特性同音密码简单替换密码凯撒密码维吉尼亚密码
每个字母的符号数多个(基于频率)恰好 1 个恰好 1 个每个位置 1 个(多字母表)
抵御频率分析部分
密钥类型符号映射表置换字母表移位值(0-25)关键词
相同明文 -> 相同密文?否(随机化)否(因位置而异)
历史用途外交、情报通用军事、教育军事、外交

现代安全评估

同音密码按现代密码学标准并不安全。尽管能抵御基本的频率分析,但它仍容易受到以下攻击:

  • 二元组和三元组分析——字母组合(TH、HE、ING)即使在单个字母频率被隐藏时仍会形成可检测的模式
  • 爬山算法——计算机每秒可以测试数百万种密钥变体,逐步收敛到正确答案
  • 可能词攻击——猜测常见短语可以大幅缩小搜索空间
  • 足够多的密文——当密文超过 1000 个符号时,统计规律必然会显现

对于真正的安全需求,请使用现代加密技术(AES-256、RSA 或认证加密)。同音密码在教育、历史研究和娱乐解谜方面仍具价值。

常见问题

同音替换和简单替换有什么区别?

在简单替换中,每个字母始终映射到一个符号,保留了频率模式。同音替换为每个字母分配多个符号,加密时随机选取其中之一。这意味着字母 E 在一条消息中可能以 12 种不同的符号出现,从而平坦化使简单替换容易被破解的频率分布。

一个好的同音密码需要多少个符号?

最少需要 50-100 个符号才能达到基本效果。长期抵御密码分析的历史系统使用了 200-600 个以上的符号。大密码的 600 多个符号为其存活 200 年做出了贡献。符号越多,频率平坦化效果越好,但密钥材料也越大,越难管理和分发。

在没有密钥的情况下能破解同音密码吗?

可以,但需要足够多的密文(通常 1000 个以上的符号)和先进的统计方法。二元组分析、可能词攻击和计算机爬山算法可以逐渐还原映射关系。佐迪亚克 Z408 在一周内被破解;大密码直到 1890 年才被破解——密文的数量和复杂度是主要决定因素。

为什么佐迪亚克杀手密码在密码学中如此著名?

佐迪亚克密码是同音替换在现实中最广为人知的应用案例之一。Z408(1969 年破解)表明即使是业余密码分析者也能破解简单的同音密码。Z340(2020 年,历经 51 年才被破解)展示了叠加换位层可以大幅增加难度。两者共同作为密码分析和手工密码系统局限性的典型案例研究。

同音密码和多字母表密码一样吗?

不一样。多字母表密码(如维吉尼亚密码)根据消息中的位置使用多个字母表,通过关键词循环切换。同音密码使用单一替换系统,每个字母对应多个符号,随机选取。两者的机制和弱点不同,但都旨在掩盖频率模式。

什么是命名符(nomenclator)?

命名符将字母级别的同音替换与整个单词、短语或专有名词的代码符号相结合。例如,单个符号可能代表"国王"或"巴黎"。这是 16 至 19 世纪欧洲外交密码的标准做法,使消息更短,并为密码破译者增加了额外的复杂性。

相关工具与资源