Homophonic Substitution Cipher
Type a message to encode it with a simplified homophonic substitution cipher.
Result
How it is calculated
The text is converted to upper case and only the letters A to Z are encoded; spaces, digits, punctuation and accented letters are skipped and not counted. The hundred codes 00 to 99 are divided among the 26 letters roughly in proportion to English letter frequency (Cornell's count from 40,000 words, rounded to whole codes so that they add up to 100): E 12, T 9, A 8, O, I and N 7, S, R and H 6, D and L 4, U 3, C, M, F, Y, W, G and P 2, and B, V, K, X, Q, J and Z 1 each. The sets do not overlap and are scattered over 00 to 99 by a fixed permutation, so every code stands for exactly one letter: that is what the Handbook of Applied Cryptography (§ 7.3.2) requires for the cipher to be decodable.
The Handbook picks a code from the letter's set at random; this tool takes them in turn (a letter's first occurrence gets the first code of its set, the next occurrence the second, and so on, starting again after the last), so the same message always gives the same output. Decode reverses it: each two-digit code is looked up and replaced by its letter. With a fixed, published table this is a teaching demo only and must not be used to protect anything.
Worked example
Encode HELLO. H has the codes 58, 95, 32, 69, 06, 43; E has twelve, starting 66, 03, 40; L has 13, 50, 87, 24; O has 94, 31, 68 and four more. Each letter takes the next unused code of its own set, so H → 58, E → 66, the first L → 13, the second L → 50 and O → 94. The tool outputs 58 66 13 50 94 and reports 5 letters. The two Ls got different codes, yet both decode to L, because 13 and 50 belong to L alone: choose Decode and enter 58 66 13 50 94 to get HELLO back.
Common mistakes
- Expecting secrecy. The code table is fixed and printed in the method, so anyone can decode the output.
- Counting spaces and punctuation as letters. Only A to Z are encoded, so 'Hello, World' gives 10 codes, not 12.
- Typing accented or non-Latin letters such as ş, ğ or ü. They are ignored; a text with no A to Z letters gives no result.
- Assuming the same letter always gets the same code, as in a plain substitution cipher. A repeated letter moves on through its own set of codes.
- Decoding with anything but two-digit codes separated by spaces or commas. A three-digit number or a letter in the input gives no result.
Sources
- Handbook of Applied Cryptography, Chapter 7: Block Ciphers (§7.3.2 (iii) Homophonic substitution) — A. Menezes, P. van Oorschot, S. Vanstone, CRC Press, 1996 (University of Waterloo CACR)
- English Letter Frequency (based on a sample of 40,000 words) — Cornell University, Department of Mathematics (Math Explorers' Club)
About this calculator
A homophonic substitution cipher improves on a plain substitution cipher (where each letter always maps to the same symbol) by giving common letters several interchangeable codes instead of just one. Because a letter like “e” might be replaced by any of several different 2-digit numbers depending on where it appears, the resulting ciphertext has a flatter, more uniform distribution of symbols, which defeats simple frequency analysis — the classic technique of counting symbol frequency to guess which cipher-symbol represents “e”, “t”, and so on.
Historical nomenclators and “great ciphers” used by diplomats and spies from the Renaissance through the 19th century (and famously the Zodiac Killer's 340-character cipher, solved only in December 2020 by David Oranchak, Sam Blake and Jarl Van Eycke) relied on this same many-to-one idea. This tool is an educational demonstration of the cipher as the Handbook of Applied Cryptography defines it: the hundred codes 00 to 99 are shared out among the letters roughly in proportion to how often each occurs in English (E has 12, T 9, A 8, and the rarest letters one each), no code belongs to two letters, and a repeated letter takes the next code in its set. So the ciphertext can always be decoded, which the tool also does, and the codes come out far more evenly than the letters.
Was this helpful?
You can pick up to 3 reactions.
Comments
- Be the first to comment.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm's Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Note from the editors
Use this for puzzles and classroom demos, not secrecy. You can check an output by hand: HELLO gives 58 66 13 50 94, and the two L's become 13 and 50 because L owns four codes and takes them in turn. Since no code belongs to two letters, Decode turns 58 66 13 50 94 straight back into HELLO. What are you using the codes for: a puzzle, a lesson, or a game?