资源 · 指南或文章
Rail Fence Cipher
讲解栅栏密码(又称之字形换位密码):字符沿各条“栏”斜向上下排列,再逐栏读出。
审核日期
打开原站: Rail Fence Cipher (在新标签页中打开原网站)添加到路线图
把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。
来源内容语言:英语
The rail fence cipher (also called a zigzag cipher) is a transposition cipher in which the message is split across a set of rails on a fence for encoding. The fence is populated with the message's characters, starting at the top left and adding a character on each position, traversing them diagonally to the bottom. Upon reaching the last rail, the direction should then turn diagonal and upwards up to the very first rail in a zig-zag motion. Rinse and repeat until the message is fully disposed across the fence. The encoded message is the result of concatenating the text in each rail, from top to bottom. From wikipedia, this is what the message WE ARE DISCOVERED. FLEE AT ONCE looks like on a 3-rail fence: The message can then be decoded by re-creating the encoded fence, with the same traversal pattern, except characters should only be added on one rail at a time. To illustrate that, a dash can be added on the rails that are not supposed to be populated yet. This is what the fence would look like after populating the first rail, the dashes represent positions that were visited but not populated.
PrepKit 概览
本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。
- 适合人群
- 来源未说明适用级别
- 形式
- 参考资料
涵盖内容
- 用文本网格画出 WE ARE DISCOVERED. FLEE AT ONCE 的三栏编码,并给出得到的密文
- 通过重放之字形路径、逐栏填充来解码,用短横线表示已经过但为空的位置
- 解码时何时开始填充下一栏
使用建议
这是 PrepKit 的学习建议,并非来源的说法。
编写适用于任意栏数的编码和解码函数,并确认对三栏密文解码后能还原原文。
范围与局限
README 中没有复杂度数据或代码;外部阅读只有一个维基百科页面和一个在线计算器。
获取方式与形式
GitHub 上采用 MIT 许可的 trekhleb/javascript-algorithms 仓库中的免费英文 README。
PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88
本概览的依据
- src/algorithms/cryptography/rail-fence-cipher/README.md
收录此条目的页面
订阅 PrepKit 通讯
可选。使用 PrepKit 并不需要订阅。