Skip to content
Also from us: TypologyOnline.com · Free personality tests

Keyword Cipher: When a Word Becomes a Secret Alphabet

How a memorable keyword builds a keyed substitution alphabet, and why the pattern still gives the game away.

Try the Keyword Cipher tool
Illustration of a keyword generating a keyed substitution alphabet
The Keyword cipher turns a memorable word into a complete substitution alphabet, but the mapping still stays fixed.

The Keyword Cipher begins with a simple human idea: use a word you can remember. Instead of shifting the alphabet by a fixed number, as in the Caesar cipher, or reversing it completely, as in Atbash, the Keyword Cipher lets a chosen word reshape the alphabet itself.

With the keyword ZEBRAS, the cipher alphabet begins with Z E B R A S. Then the remaining unused letters of the alphabet are added after it: C D F G H I J K L M N O P Q T U V W X Y. The full keyed alphabet becomes ZEBRASCDFGHIJKLMNOPQTUVWXY.

That is the charm of the Keyword Cipher. A single memorable word becomes a complete substitution alphabet. The normal alphabet maps onto this new keyed alphabet, so A becomes Z, B becomes E, C becomes B, and the rest of the alphabet follows the same fixed mapping.

But the weakness remains. The Keyword Cipher is still monoalphabetic: each plaintext letter always becomes the same ciphertext letter. If E becomes A, then every E becomes A. The keyword changes the alphabet, but it does not erase the habits of the language.

That is why the Keyword Cipher is worth learning. It shows how a key can generate a cipher system, while also showing why a hidden alphabet is not the same as real secrecy.

Keyword Cipher at a glance

Feature Keyword Cipher
Type Monoalphabetic substitution cipher
Main idea Build a keyed substitution alphabet from a cleaned keyword
Key A word or phrase
Example keyword ZEBRAS
Normalised keyword ZEBRAS
Plain alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ
Keyed alphabet ZEBRASCDFGHIJKLMNOPQTUVWXY
Example plaintext MEET AT DAWN
Example ciphertext JAAQ ZQ RZVK
Decryption method Reverse the substitution mapping
Security level Educational only; weak by modern standards
Best use Learning substitution, keyed alphabets, and frequency analysis

The Keyword Cipher builds a keyed substitution alphabet from a cleaned keyword. The keyword is written first, repeated letters are removed, and then the remaining unused letters of the alphabet are added after it.

Once that alphabet exists, encryption is just letter substitution.

Try a quick example

Use the keyword:

ZEBRAS

This creates the keyed alphabet:

ZEBRASCDFGHIJKLMNOPQTUVWXY

Now encrypt:

MEET AT DAWN

Using the normal alphabet above the keyed alphabet:

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

So:

Plain M E E T A T D A W N
Cipher J A A Q Z Q R Z V K

The result is:

MEET AT DAWN -> JAAQ ZQ RZVK

What is the Keyword Cipher?

The Keyword Cipher is a classical monoalphabetic substitution cipher. It replaces each plaintext letter with a ciphertext letter from a keyed alphabet.

The keyed alphabet is built from a keyword. For example, the keyword ZEBRAS starts the cipher alphabet:

Z E B R A S

Then the remaining unused alphabet letters are appended in ordinary order:

C D F G H I J K L M N O P Q T U V W X Y

Together, they form:

ZEBRASCDFGHIJKLMNOPQTUVWXY

This keyed alphabet is lined up beneath the normal alphabet:

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

To encrypt, look up the plaintext letter in the top row and write the matching letter from the bottom row. To decrypt, reverse the lookup.

So the keyword is not used as a repeated stream, the way it is in Vigenere. It is used once to build a full substitution alphabet.

How does the Keyword Cipher work?

The Keyword Cipher has three main stages:

  1. Clean the keyword.
  2. Build the keyed alphabet.
  3. Substitute each letter using the keyed alphabet.

Cleaning the keyword means keeping letters, uppercasing them, and removing repeats while preserving the first occurrence. With the keyword:

ZEBRAS

there are no repeated letters, so the cleaned keyword is still:

ZEBRAS

With a keyword such as:

BALLOON

the repeated letters are removed:

BALON

Only the first L and first O remain. The goal is to create a cipher alphabet with each letter appearing exactly once.

Keyword, cleaned keyword, and normalised keyword

The raw keyword is whatever the user types. A tool may accept spaces, punctuation, and mixed case:

Zebras!

The cleaned keyword keeps only letters and converts them to uppercase:

ZEBRAS

The normalised keyword removes repeated letters:

ZEBRAS

For a messier example:

Secret Message!

the cleaned letters are:

SECRETMESSAGE

After removing repeats, the normalised keyword becomes:

SECRTMAG

That normalised keyword starts the cipher alphabet. Then the unused alphabet letters are appended.

Using the CipherRegister Keyword Cipher Tool

The Keyword Cipher tool is built around the same ideas:

Control What it does
Mode Encrypt or decrypt
Keyword Builds the keyed substitution alphabet
Block size Groups encrypted output for readability
Preserve spacing Keeps spaces in their original positions
Preserve punctuation Leaves punctuation and numbers visible
Output status Explains the effective alphabet and any warnings

The important part is the effective keyed alphabet. If the keyword is valid, the tool can show the normalised keyword and the final cipher alphabet.

For the default keyword:

ZEBRAS

the effective keyed alphabet is:

ZEBRASCDFGHIJKLMNOPQTUVWXY

This is the alphabet used for every letter substitution.

Key and rules

Rule Explanation
Use a keyword The keyword starts the cipher alphabet
Remove repeated letters Each alphabet letter can appear only once
Add unused alphabet letters Fill the rest of the cipher alphabet in normal order
Substitute letter by letter Each plaintext letter maps to one fixed ciphertext letter
Preserve case if desired A tool can keep uppercase and lowercase style
Non-letters may pass through Spaces, numbers, and punctuation can be preserved
Decryption reverses the mapping Cipher alphabet letters map back to normal alphabet letters

The Keyword Cipher does not use modular arithmetic. It does not use row and column coordinates. It does not use a repeating keystream.

It uses a keyed alphabet.

That makes it easy to understand and easy to implement.

Worked example: MEET AT DAWN with ZEBRAS

Encrypt:

MEET AT DAWN

using the keyword:

ZEBRAS

First build the keyed alphabet:

Plain:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: ZEBRASCDFGHIJKLMNOPQTUVWXY

Now substitute each letter:

Plain Cipher
M J
E A
E A
T Q
A Z
T Q
D R
A Z
W V
N K

So:

MEET AT DAWN -> JAAQ ZQ RZVK

If punctuation is preserved, then:

Meet at dawn! -> Jaaq zq rzvk!

The case style is kept, but the substitution mapping is the same.

Tool options explained

Grouping ciphertext is only formatting. For example:

JAAQZQRZVK

can be grouped as:

JAAQZ QRZVK

The letters have not changed. Only the display has changed.

Preserving spaces makes the output easier to read:

JAAQ ZQ RZVK

Removing spaces makes it look more like traditional ciphertext:

JAAQZQRZVK

Preserving punctuation lets ordinary text remain readable:

Meet at dawn! -> Jaaq zq rzvk!

But from a security point of view, spaces and punctuation leak structure. Word lengths, sentence shapes, and punctuation marks can all help an attacker.

Understanding the output status

A good Keyword Cipher tool should explain what it actually used.

For example:

Status item Meaning
Cleaned keyword The letters kept after removing spaces and punctuation
Normalised keyword The keyword after duplicate letters are removed
Keyed alphabet The final cipher alphabet
Repeated letters removed Shows whether the raw keyword changed
Empty keyword warning Explains that at least one usable letter is required

This is useful because the keyword a user types is not always the keyword the cipher uses.

If someone enters:

ZEBRAS!!!

the effective keyword is still:

ZEBRAS

If someone enters:

banana

the normalised keyword becomes:

BAN

The tool should make that visible.

What leaks from a Keyword Cipher?

The Keyword Cipher hides the direct alphabet order, but it does not hide letter frequency.

English has habits. Some letters appear more often than others. Some pairs and word shapes are common. A monoalphabetic substitution preserves those habits because the mapping is fixed.

If the plaintext letter E is common, then whatever cipher letter represents E will become common too. With the ZEBRAS keyed alphabet, E maps to A, so a long encrypted English message may contain many As.

That gives a codebreaker a way in.

The Keyword Cipher changes the alphabet, but it does not change the statistical shape of the language.

History and origin

Keyword substitution belongs to the long family of simple substitution ciphers. The basic idea is old: replace each plaintext letter with another symbol or letter according to a fixed alphabet.

The keyword version makes that fixed alphabet easier to create and remember. Instead of memorising a random 26-letter substitution alphabet, the sender and receiver can agree on a word or phrase, remove repeated letters, and fill in the rest of the alphabet.

That practicality is the point.

The Keyword Cipher was not designed for modern computer security. It belongs to a world of hand ciphers, puzzles, classrooms, and paper alphabets. Its value is educational: it shows how a small key can generate a larger substitution system.

Why the Keyword Cipher was useful

The Keyword Cipher was useful because it made substitution alphabets more manageable.

Advantage Why it helped
Memorable key A word is easier to remember than a random alphabet
Simple setup The alphabet can be built by hand
Reversible Decryption uses the reverse mapping
Better than a plain alphabet shift The mapping is less obvious than Caesar
Good for teaching It shows how a key can generate a substitution alphabet

Compared with Caesar, the Keyword Cipher has many more possible alphabets. But it is still a fixed substitution cipher.

That means it is only a step forward, not a secure destination.

Weaknesses

The Keyword Cipher is weak by modern standards.

Weakness Why it matters
Monoalphabetic mapping Each plaintext letter always maps to the same ciphertext letter
Frequency patterns survive Common letters remain common after substitution
Word shapes may leak Preserved spacing reveals lengths and patterns
Human keywords are guessable People choose memorable words
No authentication It cannot detect tampering
Not modern encryption It lacks secure keys, randomness, and formal security

The biggest issue is the fixed mapping. If an attacker recovers part of the alphabet, that knowledge applies everywhere in the message.

How the Keyword Cipher is broken

A practical attack usually begins with frequency analysis.

The attacker counts ciphertext letters and compares the counts to normal English. They look for common single letters, repeated patterns, short words, doubled letters, and likely cribs.

For example, if spaces are preserved, a one-letter word is likely to be A or I. A three-letter word may be THE, AND, YOU, or ARE. Repeated patterns can also help.

Suppose a ciphertext contains a repeated word shape:

QAAQ

That shape suggests a plaintext pattern where the middle two letters are the same. It may not solve the message on its own, but every clue narrows the alphabet.

The keyword itself can also be attacked. Human keywords are often words like SECRET, CASTLE, ORANGE, DRAGON, or names and places. If the attacker guesses the keyword, the entire cipher alphabet is recovered.

Common mistakes when using a Keyword Cipher

Mistake Why it causes trouble
Forgetting to remove duplicates The cipher alphabet may contain repeated letters
Using different alphabet fill rules Sender and receiver build different alphabets
Treating grouping as encryption Grouping is only display formatting
Preserving spaces unintentionally Word lengths leak information
Expecting modern security The cipher is educational only

The most important rule is consistency. Both sides must clean the keyword, remove duplicates, and fill the alphabet in the same way.

Keyword Cipher vs Caesar Cipher

Feature Caesar Cipher Keyword Cipher
Key Number shift Word or phrase
Alphabet Shifted alphabet Keyword-built alphabet
Mapping Fixed Fixed
Type Monoalphabetic substitution Monoalphabetic substitution
Easy to brute force Very easy Harder than Caesar, but still weak
Frequency analysis Works well Works well

The Keyword Cipher is more flexible than Caesar because the alphabet is not just shifted by a number. But both ciphers preserve a fixed letter mapping.

That is why frequency analysis still works.

Keyword Cipher vs Vigenere Cipher

Feature Keyword Cipher Vigenere Cipher
Key use Builds one substitution alphabet Selects changing shifts
Mapping One fixed mapping Mapping changes by key position
Cipher type Monoalphabetic Polyalphabetic
Example key ZEBRAS LEMON
Main weakness Letter frequency survives strongly Repeated-key periodicity leaks structure

The names can be confusing because both use keywords. But the keyword does different work.

In the Keyword Cipher, the word creates a single alphabet. In Vigenere, the word controls a repeating sequence of shifts.

Cipher Relationship
Caesar cipher A simpler monoalphabetic substitution using a fixed shift
Atbash cipher A fixed alphabet reversal
Affine cipher A formula-based monoalphabetic substitution
Vigenere cipher A polyalphabetic cipher using a repeated keyword
Frequency analysis The main attack against simple substitution ciphers

The Keyword Cipher is a useful bridge between Caesar and full substitution alphabets. It shows how a key can create a complete alphabet without needing the sender to memorise all 26 substitutions directly.

A simple Python Keyword Cipher

The code below implements a small educational Keyword Cipher. It:

Feature Behaviour
Cleans the keyword Keeps letters and uppercases them
Removes duplicates Keeps the first occurrence of each letter
Builds the keyed alphabet Keyword first, then unused letters
Encrypts text Normal alphabet to keyed alphabet
Decrypts text Keyed alphabet back to normal alphabet
Preserves non-letters Spaces, punctuation, and numbers pass through
Preserves case Uppercase and lowercase style are kept
Python exampleShow code
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


def clean_keyword(keyword):
    """
    Keep letters only, uppercase them, and remove duplicates.
    """
    cleaned = ""
    seen = set()

    for char in keyword.upper():
        if char.isalpha() and char not in seen:
            seen.add(char)
            cleaned += char

    if cleaned == "":
        raise ValueError("Keyword must contain at least one letter.")

    return cleaned


def build_cipher_alphabet(keyword):
    """
    Build the keyed substitution alphabet.

    Example:
        ZEBRAS -> ZEBRASCDFGHIJKLMNOPQTUVWXY
    """
    cleaned = clean_keyword(keyword)
    cipher_alphabet = cleaned

    for letter in ALPHABET:
        if letter not in cipher_alphabet:
            cipher_alphabet += letter

    return cipher_alphabet


def make_maps(keyword):
    """
    Build encryption and decryption lookup dictionaries.
    """
    cipher_alphabet = build_cipher_alphabet(keyword)

    encrypt_map = {}
    decrypt_map = {}

    for plain, cipher in zip(ALPHABET, cipher_alphabet):
        encrypt_map[plain] = cipher
        decrypt_map[cipher] = plain

    return encrypt_map, decrypt_map


def transform(text, lookup):
    """
    Transform text using a substitution lookup.
    """
    output = []

    for char in text:
        if char.isalpha():
            upper = char.upper()
            mapped = lookup[upper]

            if char.isupper():
                output.append(mapped)
            else:
                output.append(mapped.lower())
        else:
            output.append(char)

    return "".join(output)


def encrypt(text, keyword):
    """
    Encrypt text with the Keyword Cipher.
    """
    encrypt_map, decrypt_map = make_maps(keyword)
    return transform(text, encrypt_map)


def decrypt(text, keyword):
    """
    Decrypt text with the Keyword Cipher.
    """
    encrypt_map, decrypt_map = make_maps(keyword)
    return transform(text, decrypt_map)


# Example
keyword = "ZEBRAS"
plaintext = "Meet at dawn!"

ciphertext = encrypt(plaintext, keyword)
decrypted = decrypt(ciphertext, keyword)

print("Keyword   :", keyword)
print("Alphabet  :", build_cipher_alphabet(keyword))
print("Plaintext :", plaintext)
print("Encrypted :", ciphertext)
print("Decrypted :", decrypted)

Expected output:

Keyword   : ZEBRAS
Alphabet  : ZEBRASCDFGHIJKLMNOPQTUVWXY
Plaintext : Meet at dawn!
Encrypted : Jaaq zq rzvk!
Decrypted : Meet at dawn!

The key line is:

cipher_alphabet = cleaned

followed by:

for letter in ALPHABET:
    if letter not in cipher_alphabet:
        cipher_alphabet += letter

That is the whole alphabet-building step. The keyword starts the alphabet, and the unused letters complete it.

Reading the code like the cipher

The function clean_keyword(keyword) turns a raw keyword into the usable keyword. If the user enters:

Zebras!

the cleaned keyword becomes:

ZEBRAS

The function build_cipher_alphabet(keyword) then appends every unused alphabet letter:

ZEBRASCDFGHIJKLMNOPQTUVWXY

The function make_maps(keyword) creates two dictionaries:

Map Direction
encrypt_map Plain alphabet to keyed alphabet
decrypt_map Keyed alphabet to plain alphabet

Encryption and decryption use the same substitution engine. Only the lookup map changes.

That is exactly how the cipher works by hand.

Common questions about the Keyword Cipher

Is the Keyword Cipher secure?

No. The Keyword Cipher is not secure by modern standards. It is a monoalphabetic substitution cipher, so frequency analysis and crib-based attacks work against it.

It is useful for learning, puzzles, and historical interest only.

Is the Keyword Cipher the same as Caesar?

No. Caesar uses a numeric shift. The Keyword Cipher uses a word or phrase to build a full substitution alphabet.

But both are monoalphabetic substitution ciphers, so both preserve fixed letter mappings.

What happens if the keyword has repeated letters?

Repeated letters are removed after their first occurrence.

For example:

BALLOON -> BALON

The cipher alphabet must contain each letter only once.

Can spaces and punctuation be preserved?

Yes. A tool can preserve spaces, punctuation, numbers, and case for readability.

But preserving them leaks structure. Classical ciphertext often removes or groups spacing to reduce those clues.

What is a good Keyword Cipher example?

Item Value
Keyword ZEBRAS
Keyed alphabet ZEBRASCDFGHIJKLMNOPQTUVWXY
Plaintext MEET AT DAWN
Ciphertext JAAQ ZQ RZVK

This is the example used in the Keyword Cipher tool.

Is a keyword the same as a key?

In this cipher, yes. The keyword is the key material used to build the substitution alphabet.

But the final effective key is really the full keyed alphabet, because that is what controls every letter mapping.

Why the Keyword Cipher still matters

The Keyword Cipher should not be used to protect anything serious. Not passwords. Not private messages. Not financial data. Not API keys. Not recovery phrases.

Modern encryption depends on carefully analysed algorithms, large keys, secure randomness, authentication, and resistance to many kinds of attack. The Keyword Cipher has none of that.

But it still earns its place.

It shows how a memorable key can generate a larger cipher system. It shows why removing duplicate key letters matters. It shows how substitution alphabets are built. It shows why fixed mappings leak language patterns. It shows why frequency analysis is so powerful.

And most importantly, it teaches that a key is not magic by itself.

A keyword can make the alphabet look secret. It can make the cipher feel more personal and more flexible than Caesar. But if the mapping stays fixed, the language still leaves fingerprints.

That is why the Keyword Cipher still matters. Not because it is strong, but because it teaches the difference between a hidden alphabet and a secure cipher.

Try the Keyword Cipher tool

Use the Keyword Cipher tool to build a keyed alphabet from your own word, encrypt a short message, and inspect the effective alphabet the tool creates.

Start with:

Setting Value
Keyword ZEBRAS
Plaintext MEET AT DAWN
Expected ciphertext JAAQ ZQ RZVK

Then try a keyword with repeated letters, such as BALLOON, and notice how the tool normalises it before building the alphabet.

Sources and further reading

Try the Keyword Cipher Tool

Want to experiment with the idea in practice? Open the matching tool and try your own text.

Open Keyword Cipher
Signal acquired

A note from the team

We build these tools because we love cryptography, encoding, and making difficult ideas easier to explore. If they've helped you, even a small coffee means the world to the project. Thank you!

Say thanks on Ko-fi

Read next

Substitution Caesar Cipher: A Secret in Plain Sight Why the world's easiest cipher to break is still the perfect place to start learning. Substitution Atbash Cipher: The Alphabet in a Mirror How one of the oldest substitution ciphers turns A into Z, B into Y, and the alphabet into its own reflection. Cryptanalysis Frequency Analysis: The Statistical Fingerprint That Broke Classical Ciphers How counting letters turned cryptanalysis from educated guesswork into a science, and why weak ciphers still betray themselves through the shape of language.
Back to all articles