Skip to content

Substitution cipher decoder and encoder with key

Provide all 26 replacement letters once, then encode with the mapping or decode through its exact inverse. This tool never guesses a missing key.

Cipher input

Processed in your browser.

Up to 500 characters. Only English A–Z letters change; case, spaces, punctuation, numbers, and other scripts are preserved.

Enter each English letter exactly once. Example: QWERTYUIOPASDFGHJKLZXCVBNM maps ABC…XYZ to QWE…BNM.

Converted text

Enter a short message, then select Convert.

How to use the keyed substitution cipher

  1. Enter a short plaintext or ciphertext message and choose Encode or Decode. The message may contain spaces, punctuation, numbers, and other scripts, but it must include at least one English A–Z letter.
  2. Enter exactly 26 letters in the key field. The first key letter replaces A, the second replaces B, and so on through Z. A valid key is a permutation: every A–Z letter appears once.
  3. Select Convert. Encode follows the plain-to-key alphabet; Decode constructs the inverse mapping from the same key.
  4. Copy result copies only the converted message. Editing the message, key, or direction immediately clears the previous result and copied status.

How a 26-letter substitution key works

Write the ordinary alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ above the key alphabet. With the example QWERTYUIOPASDFGHJKLZXCVBNM, A maps to Q, B to W, C to E, and Z to M. Encoding replaces each plaintext letter using that column. Decoding reverses the lookup: Q maps back to A, W to B, and M to Z.

A complete permutation is required so that every ciphertext letter has one and only one plaintext partner. A missing letter makes part of the mapping undefined; a repeated letter makes the inverse ambiguous. The validator therefore distinguishes wrong length, non-A–Z characters, and duplicates rather than attempting to repair the key. Key case is ignored, while the case of each message letter is preserved.

Only unaccented English letters in the message are substituted. Spaces, punctuation, digits, emoji, accented letters, Korean, Japanese, and other scripts remain at their original positions. Unlike Vigenère, the mapping never advances with position: the same plaintext letter always produces the same ciphertext letter.

Exact substitution examples

Key QWERTYUIOPASDFGHJKLZXCVBNM maps ABC XYZ → QWE BNM. Decode QWE BNM with the same key to recover ABC XYZ. This alphabet-edge vector checks both ends of the mapping.

With the same key, HELLO! → ITSSG!. Decoding ITSSG! returns HELLO!, while the exclamation mark remains unchanged. These vectors are asserted independently in the feature tests.

When this translator is useful

Key requirements and security limits

Substitution cipher FAQ

What order do the 26 key letters use?

Position 1 replaces A, position 2 replaces B, and position 26 replaces Z. The ordinary alphabet is the fixed source row.

Why are duplicate letters rejected?

Two plaintext letters would share one ciphertext letter, so decoding could not choose a unique original. A permutation prevents that ambiguity.

Does Decode need a second inverse key?

No. The tool builds the inverse lookup from the same valid 26-letter key.

Can this solve ciphertext without a key?

No. Automatic key search and frequency analysis are explicitly outside this exact-mapping translator.