关键字密码 — 在线替换密码解码器和编码器

The Keyword cipher is a monoalphabetic substitution cipher that creates a scrambled alphabet from a secret keyword. Each letter is replaced by its corresponding position in the custom alphabet — making it harder to crack than a simple Caesar shift. Use this free ciphertext decoder and encoder to encrypt, decrypt, and break keyword-based substitution ciphers with built-in frequency analysis.

"HELLO""GJKKF"(Keyword: ZEBRA)
结果
0 字符
Keyword:
Options:Preserve Case

Alphabet Mapping

Standard Alphabet

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

Cipher Alphabet

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Enter a keyword to see the cipher alphabet

How the Keyword Cipher Works

Cipher Alphabet Generation

The keyword cipher generates a substitution alphabet from your keyword. First, duplicate letters are removed from the keyword. Then the remaining unused letters of the standard alphabet are appended in order.

Keyword: ZEBRA

Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ

Cipher: ZEBRACKDFGHIJLMNOPQSTUVWXY

Encryption & Decryption

To encrypt, replace each plaintext letter with its corresponding cipher alphabet letter. To decrypt, reverse the mapping. Each letter always maps to the same substitute, making this a monoalphabetic substitution cipher.

Plain: HELLO WORLD

Cipher: CAKKM VMOKA

H→C, E→A, L→K, O→M, W→V ...

Ciphertext Decoder & Substitution Cipher Solver

Our keyword cipher tool doubles as a general-purpose ciphertext decoder for any monoalphabetic substitution cipher. The built-in frequency analysis engine compares letter distributions against known language patterns to automatically crack encrypted text — even without knowing the keyword.

Frequency Analysis

Compares ciphertext letter frequencies against English language statistics (E=12.7%, T=9.1%, A=8.2%) to identify substitution mappings.

Pattern Matching

Identifies common digraphs (TH, HE, IN) and trigraphs (THE, AND, ING) to verify and refine letter mappings.

Auto Solver

Combines statistical scoring with dictionary validation to automatically recover the plaintext from any monoalphabetic cipher.

Frequently Asked Questions About Keyword Cipher

What is a Keyword cipher?

A Keyword cipher is a monoalphabetic substitution cipher that generates a scrambled alphabet from a secret keyword. The keyword's unique letters are placed at the start of the cipher alphabet, and the remaining unused letters follow in standard alphabetical order. Each plaintext letter is then replaced by its corresponding letter in this new cipher alphabet. It is one of the simplest and most widely taught classical encryption methods.

How do you create a Keyword cipher alphabet?

To create a Keyword cipher alphabet, first write out the keyword with any duplicate letters removed. Then append the remaining letters of the standard alphabet in order, skipping any that already appeared in the keyword. For example, the keyword 'ZEBRA' produces the cipher alphabet 'ZEBRACKDFGHIJLMNOPQSTUVWXY'. Each plaintext letter maps to the letter at the same position in this cipher alphabet.

How do you decrypt a Keyword cipher?

To decrypt a Keyword cipher when you know the keyword, reverse the substitution by mapping each ciphertext letter back to its plaintext equivalent using the generated cipher alphabet. Without the keyword, use frequency analysis: since each plaintext letter always maps to the same ciphertext letter, compare the most common ciphertext letters to known English letter frequencies (E, T, A) to deduce mappings. Pattern analysis of digraphs like 'TH' and common words also helps recover the key.

What makes a good keyword for encryption?

A good keyword contains many unique letters to maximize alphabet scrambling. Longer keywords with no repeated letters, such as 'COMPLEXITY' or 'JUXTAPOSED', rearrange more of the alphabet and make the cipher harder to guess. Short keywords or common words like 'CAT' shift very few letters and produce a cipher alphabet that closely resembles the original, making it easier to crack. Ideally, choose an uncommon word with 8-10 distinct letters.

How is Keyword cipher different from Caesar cipher?

The Caesar cipher shifts every letter by a fixed number of positions, producing only 25 possible cipher alphabets. The Keyword cipher rearranges the alphabet using a keyword, allowing for a vastly larger number of possible alphabets. While both are monoalphabetic substitution ciphers, the Keyword cipher is significantly harder to brute-force because you cannot simply try all shift values — you must determine the full substitution mapping.

Can frequency analysis break a Keyword cipher?

Yes, frequency analysis is the primary method for breaking Keyword ciphers. Because each plaintext letter consistently maps to the same ciphertext letter, the statistical distribution of letters is preserved. With roughly 25-30 characters of ciphertext, an analyst can begin matching high-frequency ciphertext letters to common English letters. Longer ciphertexts make the attack even more reliable.

What are real-world uses of Keyword ciphers?

Keyword ciphers have been used historically by military and diplomatic correspondents to protect sensitive messages before modern encryption existed. Today they are primarily used in education to teach cryptography fundamentals, in puzzle and escape-room games, in geocaching challenges, and in competitive cipher-solving events. They also serve as a foundation for understanding more advanced substitution and polyalphabetic ciphers.

How do you solve a substitution cipher without the key?

To solve a substitution cipher without the key, start with frequency analysis — compare how often each ciphertext letter appears against known English letter frequencies. The most common ciphertext letter likely represents E (12.7%), T (9.1%), or A (8.2%). Next, look for common patterns: single-letter words are probably 'A' or 'I', and the most frequent three-letter words are often 'THE' or 'AND'. Our decoder automates this process with statistical scoring and pattern matching.

What is a monoalphabetic substitution cipher?

A monoalphabetic substitution cipher replaces each letter of the alphabet with exactly one other letter, using a single fixed substitution alphabet. The Keyword cipher is a common type where the substitution alphabet is generated from a keyword. Unlike polyalphabetic ciphers (such as Vigenère), the same plaintext letter always maps to the same ciphertext letter, which preserves letter frequency patterns and makes the cipher vulnerable to frequency analysis.

What is the difference between a keyword cipher and a substitution cipher?

A keyword cipher is a specific type of substitution cipher. All keyword ciphers are substitution ciphers, but not all substitution ciphers use keywords. The keyword cipher generates its substitution alphabet by placing a keyword's unique letters first, then appending the remaining letters in order. Other substitution ciphers include the Caesar cipher (shift-based), Atbash (reversed alphabet), Affine (mathematical formula), and random substitution (completely random mapping).

关键词密码:古典替换加密 - 免费在线工具

关键词密码(Keyword Cipher),又称单表替换密码,是一种使用关键词创建唯一密码字母表的古典加密技术。与简单的位移密码不同,关键词密码提供可变的替换模式,使其对基本密码分析更具抵抗力,同时保持较好的教育可及性。

关键词密码的工作原理

关键词密码通过将选定的关键词置于密码字母表开头,后跟其余字母的标准字母顺序,来创建替换字母表

算法流程
  1. 关键词准备:去除重复字母并转换为大写

    • 示例:"grandmother" → "GRANMOTHE"
  2. 剩余字母:识别不在关键词中的字母

    • 剩余:BCDFIJKLPQSUVWXYZ
  3. 密码字母表:合并关键词 + 剩余字母

    • 最终:GRANMOTHEBCDFIJKLPQSUVWXYZ
  4. 字母映射:创建替换表

    • A→G,B→R,C→A,D→N,E→M……
完整示例
关键词:  "ZEBRAS"
标准:    ABCDEFGHIJKLMNOPQRSTUVWXYZ
密码:    ZEBRASCDFGHIJKLMNOPQTUVWXY

消息:    "MEET AT DAWN"
加密:    "KIIQ ZQ NZVO"

免费在线关键词密码工具功能

我们的综合关键词密码工具包括:

  • 双向处理:加密和解密模式
  • 自定义关键词:使用任意关键词生成唯一密码字母表
  • 大小写保留:保持原始文本格式的选项
  • 字符集支持:适当处理空格和标点
  • 字母映射可视化:查看字母变换方式
  • 频率分析:内置统计分析工具
  • 随机关键词生成器:自动生成安全关键词

安全分析与密码分析

尽管在历史上具有重要意义,关键词密码根本上容易受到现代密码分析技术的攻击:

频率分析脆弱性
  • 方法:字母频率的统计分析
  • 要求:约 27.6 个字母的密文
  • 过程:将密码频率与预期英文频率比较(E=12.02%,T=9.06%,A=8.12%)
  • 成功率:有足够文本时非常高
模式识别攻击
  • 方法:识别常见词汇和模式
  • 目标:冠词("THE"、"AND"),重复词
  • 指标:词长、标点模式
  • 自动化:现代算法可处理数千种可能性

相关密码方法

探索这些相关的古典加密技术

延伸阅读

探索关键词密码历史、高级密码分析和代码实现: