Monoalphabetic Substitution

Cipher that replaces letters with letters/characters

python --plainAlphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' --cipherAlphabet 'BCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzA' --encrypt  --message 'Hello this is a test. Please enter your text here.' --keep-non-alp
Select a theme:


One of the oldest of cipher types was the simple substitution or monoalphabetic substitution ciphers in which each letter of the alphabet is replaced by another letter. Each plaintext letter is substituted by a unique ciphertext letter. The earliest known example is the Atbash cipher which is found in the Old Testament and dates from around 600-500BC. It uses the Hebrew alphabet where the first letter of the Hebrew alphabet is replaced by the last letter, the 2nd letter is replaced by the 2nd to last letter and so on. Using the English alphabet the Atbash substitution is:

Atbash cipher

 Plaintext: abcdefghijklmnopqrstuvwxyz

Another example is the Caesar cipher which was used by the Roman general and statesman Julius Caesar (100 BC-44 BC) to exchange messages with Marcus Tullius Cicero (106 BC-43 BC) and others. In this type each plaintext letter was replaced by the letter standing three places further along in the alphabet. So plaintext letter A is replaced by ciphertext letter D, B is replaced by E and so on. The full substitution is:

Caesar cipher

 Plaintext: abcdefghijklmnopqrstuvwxyz

Later versions of the substitution cipher used a keyword to create a keyed alphabet which can be used for the plaintext alphabet, the ciphertext alphabet or both. Where word divisions are kept the American Cryptogram Association (ACA) refers to the monoalphabet substitution cipher as the "Aristocrat" cipher. Another type of cipher, the Patristocrat, uses the same method of encryption but normal word divisions are not retained. An additional "rule" used by the ACA is that no plaintext letter can be substituted by the same ciphertext letter so the keyed alphabets can be shifted to avoid this. Four types of substitution are used depending on how the keyed alphabet is used and these are known in the ACA as keyword types K1, K2, K3 and K4.

K1 Keyword: Keyed plain alphabet, straight cipher alphabet

    pt: gcarlinbdefhjkmopqstuvwxyz

K2 Keyword: Straight plain alphabet, keyed cipher alphabet

    pt: abcdefghijklmnopqrstuvwxyz

K3 Keyword: Keyed plain alphabet, keyed cipher alphabet with the same keywords

    pt: gcarlinbdefhjkmopqstuvwxyz

K4 Keyword: Keyed plain alphabet, keyed cipher alphabet with different keywords

    pt: gcarlinbdefhjkmopqstuvwxyz

The following examples encipher the George Carlin quote "To be intoxicated is to feel sophisticated but not be able to say it.” using the four keyword types and the keyed alphabets shown above.

Type: Monoalphabetic Substitution
Keyword Type: K1
Plaintext keyword: GCARLIN

 Plaintext: to be intoxicated is to feel sophisticated but not be able to say it Ciphertext: JF XZ VWJFNVRSJZY VI JF AZZU IFGBVIJVRSJZY XKJ WFJ XZ SXUZ JF ISO VJ 

Type: Monoalphabetic Substitution
Keyword Type: K2
Ciphertext keyword: GCARLIN

 Plaintext: to be intoxicated is to feel sophisticated but not be able to say it Ciphertext: LZ JO TYLZDTKHLOM TR LZ POOW RZGSTRLTKHLOM JIL YZL JO HJWO LZ RHE TL 

Type: Monoalphabetic Substitution
Keyword Type: K3
Plaintext keyword: GCARLIN
Ciphertext keyword: GCARLIN

 Plaintext: to be intoxicated is to feel sophisticated but not be able to say it Ciphertext: RZ QT OPRZBOHJRTS OA RZ UTTM AZGVOAROHJRTS QLR PZR QT JQMT RZ AJD OR 

Type: Monoalphabetic Substitution
Keyword Type: K4
Plaintext keyword: GCARLIN
Ciphertext keyword: QUOTE

 Plaintext: to be intoxicated is to feel sophisticated but not be able to say it Ciphertext: CT VX RSCTHRLMCXW RB CT YXXP BTEZRBCRLMCXW VDC STC VX MVPX CT BMI RC 

Description of the process

The monoalphabetic substitution takes a letter of an alphabet and substitutes it with another letter, this way a ciphertext is generated. The way of converting is fixed. A character of the plaintext will be replaced by the same ciphertext character, during the entire ciphertext. There is no additional key. The only way of security is to keep the substitution-table secret. A popular example for the monoalphabetic substitution is the caesar cipher.


The Monoalphabetic substitution can easily be cracked with a frequency-analysis.


● Substitution cipher:

About the code

In this plugin you can control the encryption process in two ways:

  • via the GUI
  • via the command line arguments for the Python program

The Python code is executed purely locally in your browser without the need to install a Python development environment, but also without, that the Python code must be executed somewhere in the cloud. The following parameters can be changed via the GUI:

  • the text to be entered
  • whether to encrypt or decrypt the entered text
  • the key
  • the plaintext alphabet
  • the ciphertext alphabet
  • whether the output text should be output in blocks of five.

These GUI parameters are passed on the command line to the Python program. Changes in the GUI change the respective command line parameters. There can be four substitution types, defined by ACA [1], used: K1, K2, K3 and K4.

The code is a simple implementation of the Monoalphabetic Substitution in Python. Depending on whether the input is decrypted or encrypted the corresponding function is executed. For each character in the entered text, it is determined whether the character in the plaintext- or ciphertext alphabet. If the character in the alphabet, the key is used to find the new character is determined. In case an input character is not included in the alphabet and the checkbox "Keep characters not contained in the alphabet" is checked is not selected, the character is taken over unchanged (for example special characters). If the checkbox "Not in alphabet Retain contained characters" is selected, the character is not taken over . If a check mark is placed in the "Blocks of 5" checkbox the output is displayed in blocks of five.

About the editor

The editor available on this page was implemented with CodeMirror [1]. CodeMirror is a versatile text editor that is implemented in JavaScript for the Browser was implemented. CodeMirror has a number of add-ons for different of programming languages. Pyodide [2] is used to execute the Python code.

Pyodide brings the Python runtime environment via WebAssembly into the browser, together with NumPy, Pandas, Matplotlib, parts of SciPy and NetworkX. In the editor there is now an interpreter for Python 3.x . You can see which exact Python version is used by Pyodide – by adding the following statement to the code: print(sys.version).


[1] ACA (American Cryptogram Association) :
[2] Codemirror: