# 猪圈密码

**猪圈密码**是一种几何替换密码，字母表中的每个字母都被替换为一个符号，该符号由围绕其所属格子的网格线构成，因此一段密文看起来像是一连串棱角分明的碎片，而非字母。它也被称为共济会密码、共济会员密码、拿破仑密码和井字棋密码。<sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup>

| 关键事实 | 详情 |
|---|---|
| 密码类型 | 几何简单替换：字母被替换为网格碎片的符号<sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup> |
| 符号集 | 由两个网格和两个X形图案导出的几何符号，覆盖字母表全部26个字母<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup> |
| 最早记载 | 早在1531年即被德国博学家海因里希·科尔内利乌斯·阿格里帕在《论秘术哲学三书》中提及<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> |
| 共济会采用 | 18世纪因共济会使用而变得普遍，该系统因此得名“共济会员密码”<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> |
| 战时使用 | 美国独立战争期间被英方使用；独立战争时期的一本黑森雇佣兵日记部分以猪圈密码写成，该密码一直使用到美国南北战争<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup><sup> • </sup><sup>[4](https://www.scientificamerican.com/podcast/episode/invisible-ink-and-other-science-of-10-04-20/)</sup> |
| 安全性 | 单表替换，在密码学上等同于任何固定的字母—符号映射，可用相同的频率分析破解<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup> |
| 现代用途 | 用于密室逃脱、解谜寻宝、童子军活动和学校密码学课程等娱乐与教育场景<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup> |

## 密码原理

标准密钥由四个网格构成。字母A到I填入一个3×3的井字棋盘，J到R填入第二个棋盘，剩余的字母S到Z则置于两个X形网格中。一个字母的符号就是围住其格子的那组线条：方形网格左上角的字母画成一个开口朝下和朝左的直角，X形网格中心的字母则画成完整的X形。<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup><sup> • </sup><sup>[6](https://people.sc.fsu.edu/~jpeterson/cryptography.pdf)</sup>

由于两个字母共用一个格子形状，圆点用来标记格子中的第二个字母。在常见排列中，A和E占据同一个角落位置，因此A是光秃秃的角，E是同一个角加一个点；若某个格子要分配第三个字母，则带两个点。<sup>[7](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)</sup> 这个名字正来自这种视觉逻辑：每个字母都坐在包围它的“猪圈”之中。<sup>[7](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)</sup>

密钥很容易凭记忆重建，因为网格的布局合乎逻辑，这也是该系统得以广泛手工传播的原因之一。<sup>[8](https://publications.cedarville.edu/cedrus_press/invitation_to_cybersecurity/149/)</sup>

## 历史

网格替换的想法早于其兄弟会渊源。猪圈式密码早在1531年即被海因里希·科尔内利乌斯·阿格里帕提及，而一个前身——后来被称为“九室卡巴拉”——将希伯来字母表而非拉丁字母表安排在网格室中，服务于宗教象征意义，而非任何明显的密码学目的。<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup><sup> • </sup><sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup>

**共济会的使用。** 猪圈密码在18世纪因共济会采用而变得普遍，以至于该系统被称为“共济会员密码”。<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> 据一份参考摘要称，英国共济会到1737年前后已标准化了一种特定的四网格版本，在会所通信中非正式使用，尽管网格概念本身几乎可以肯定早于任何单一兄弟会对它的使用。<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup> 该密码的变体也被玫瑰十字兄弟会使用。<sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup> 这一传统的存世证据既有文献也有实物：带有用该密码书写的文字的共济会墓碑已被发现，年代可追溯至17世纪末，其中一块位于纽约市三一教堂公墓。<sup>[9](https://read-em-again.cdn.bibliopolis.com/images/upload/catalog-26-3-for-printing.pdf)</sup>

**战时及后来的使用。** 该密码并不局限于会所。据HISTORY网站引述的弗雷里报道，猪圈密码在美国独立战争期间曾被英方使用。<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> 《科学美国人》关于独立战争间谍技术的文章指出，当时的一本黑森雇佣兵日记部分以猪圈密码写成，且该密码一直使用至美国南北战争。<sup>[4](https://www.scientificamerican.com/podcast/episode/invisible-ink-and-other-science-of-10-04-20/)</sup> 莫斯科国立图书馆藏有一份18世纪中期以法文写成的共济会手稿，其中也出现了一张猪圈密码表。<sup>[10](https://dspace.ut.ee/bitstreams/18c0caf0-518f-4329-ad7f-8c2ad121f0cc/download)</sup>

对于搜寻共济会档案的人来说，有一点区别很重要：为美国共济会仪式出版的“密码书”，如《Ecce Orienti》和《所罗门王及其追随者》，以另一种方式编码仪式文本，与猪圈密码完全不同，尽管在网上搜索共济会密码会很快出现猪圈密码。<sup>[11](https://www.srmml.org/magicians-magic-movements-and-ceremonies/)</sup>

## 密码分析

猪圈密码并不比用其他字母作替换提供更多安全性。它是一种使用符号代替字母的简单单表替换，在密码学上等同于凯撒密码或任何其他固定的字母—符号映射，可用相同的频率分析破解。<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup> 猪圈密文中出现最频繁的符号对应源语言中最常见的字母——英语中为E、T、A、O、I和N——一旦识别出足够多的字母，部分单词便变得可读，上下文会补全其余部分。<sup>[12](https://caesarcipher.org/learn/pigpen-cipher-masonic-history-variations)</sup><sup> • </sup><sup>[13](https://matheverywhere.pages.oit.duke.edu/course/Modules/cryptography/notes.html)</sup> 只要解读者能认出符号，破解猪圈密文并不很难，短消息可供分析的文本较少，但仍可能被常见猜测攻破。<sup>[7](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)</sup><sup> • </sup><sup>[14](https://www.itechguides.com/how-to-write-using-codes-and-secret-ciphers/)</sup>

一个实际问题是，印刷的密钥各不相同。印刷的猪圈密钥在网格顺序、使用圆点还是马耳他十字布局等细节上存在差异，因此两份印刷密钥可能并非逐格对应；通信双方应确认使用的是完全相同的密钥。<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup>

## 现代用途

猪圈密码的现代用途绝大多数是娱乐性的，而非真正隐藏什么。由于其符号在普通受众看来既神秘又有趣，却不需要任何真正的密码分析，密室逃脱和解谜寻宝的道具便青睐于它；童子军和学校的密码学课程将其作为替换密码的第一堂实践课；共济会或秘术主题的小说和游戏也一再使用它。<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup> 教育机构直接使用它：美国国家标准与技术研究院（NIST）的“国家网络安全教育计划”发布了一项基于该密码的K-12活动，<sup>[15](https://www.nist.gov/document/ccawpig-pen-cipher508compliantpdf)</sup> 国际间谍博物馆在其密码资源包中加入了猪圈密码练习，<sup>[16](https://www.spymuseum.org/education-programs/educators/educator-resources/resource-kit-codes/)</sup> 而雷丁博物馆等机构举办家庭工作坊，参与者在其中寻找猪圈符号并破解编码信息。<sup>[17](https://www.readingmuseum.org.uk/family-digi-workshop-code-breaking-%E2%80%93-pigpen)</sup>

该密码持久的吸引力在于视觉。它把拉丁字母表熟悉的形状转换成看起来古老、神秘且刻意为之的符号，这使它成为前数字时代加密的天然例证，尽管它提供的密码学安全性微乎其微。<sup>[12](https://caesarcipher.org/learn/pigpen-cipher-masonic-history-variations)</sup><sup> • </sup><sup>[18](https://www.unidesktesting.motion.ac.in/oconstryctp/63F595P/lrasnu/40F380398P/codes%2Band%2Bciphers%2Ba%2Bhistory%2Bof%2Bcryptography.pdf)</sup>

## References

1. [Pigpen cipher, The Masonic Wiki](https://masonicwiki.org/wiki/Pigpen_cipher)
2. [Pigpen Cipher, The Cipher Museum](https://ciphermuseum.com/ciphers/pigpen.html)
3. [8 Ciphers That Shaped History, HISTORY](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)
4. [Invisible Ink and More: The Science of Spying in the Revolutionary War, Scientific American](https://www.scientificamerican.com/podcast/episode/invisible-ink-and-other-science-of-10-04-20/)
5. [Pigpen Cipher — Full Reference Chart, DotDashKey](https://dotdashkey.com/reference/pigpen-cipher/)
6. [people.sc.fsu.edu](https://people.sc.fsu.edu/~jpeterson/cryptography.pdf)
7. [The Pigpen Cipher, Purdue CERIAS activity sheet / Florida State cryptography notes](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)
8. [Invitation to Cybersecurity, Cedarville University](https://publications.cedarville.edu/cedrus_press/invitation_to_cybersecurity/149/)
9. [Read 'Em Again Books catalog: Masonic Royal Arch Cypher manuscript (1839)](https://read-em-again.cdn.bibliopolis.com/images/upload/catalog-26-3-for-printing.pdf)
10. [Sources of Alchemical Cryptography, University of Tartu dSpace](https://dspace.ut.ee/bitstreams/18c0caf0-518f-4329-ad7f-8c2ad121f0cc/download)
11. [Magicians' Magic Movements and Ceremonies, Scottish Rite Masonic Museum & Library](https://www.srmml.org/magicians-magic-movements-and-ceremonies/)
12. [Pigpen Cipher History: From Masonic Lodges to Pop Culture Phenomenon, CaesarCipher.org](https://caesarcipher.org/learn/pigpen-cipher-masonic-history-variations)
13. [Cryptography Course Notes, Math Everywhere, Duke University](https://matheverywhere.pages.oit.duke.edu/course/Modules/cryptography/notes.html)
14. [How to Write Secret Messages: Codes and Ciphers Explained, ITechGuides](https://www.itechguides.com/how-to-write-using-codes-and-secret-ciphers/)
15. [Cybersecurity CyberSnack: Pig Pen Cipher, NIST NICE K-12](https://www.nist.gov/document/ccawpig-pen-cipher508compliantpdf)
16. [SPY Resource Kit: Codes, International Spy Museum](https://www.spymuseum.org/education-programs/educators/educator-resources/resource-kit-codes/)
17. [Family Digi-Workshop: Code Breaking – Pigpen, Reading Museum](https://www.readingmuseum.org.uk/family-digi-workshop-code-breaking-%E2%80%93-pigpen)
18. [Codes and Ciphers: A History of Cryptography (PDF)](https://www.unidesktesting.motion.ac.in/oconstryctp/63F595P/lrasnu/40F380398P/codes%2Band%2Bciphers%2Ba%2Bhistory%2Bof%2Bcryptography.pdf)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026; Nov 11, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Discrete mathematics

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/pigpen-cipher

English original: https://www.edgepedia.org/pigpen-cipher
