Encode and decode secret messages
Detailed instructions
How to decode
1. Check one of the 4 choices below.
Send me a coded secret message.
Send me the answer to secret message number
Encode my message (typed in the box below).
Decode my message (typed in the box below).
Type the message to encode :
2. Check or fill in the information below.
Type of code: Addition
or
Multiplication
Letters to numbers: A=0, B=1, ..., Z=25
or
A=2, B=3, ..., Z=27
Modulus:
(must be an integer at least 26 if A=0, and at least 28 if A=2)
Encoding number:
Encoding number:
(must be an integer; see below for requirements for multiplication codes)
3. Click the appropriate button.
Detailed instructions
(dos and don'ts)
Message area:
Don't type lines longer than the window; hit the Return key at the end of each line.
(When the message is encoded, it takes up more space. In particular, the window is about the right width so that, when you print the encoded message, each original line will fit on a line, without putting in any additional spaces.)
Don't use any numerals--they don't get encoded and they would confuse the message recipient. Spell out any numbers you need.
Type of code:
Addition codes are much easier to decode than multiplication codes. See
below
for more information on decoding.
Letters to numbers:
For a multiplication code, starting with A=2 is recommended, for a code that is harder to crack. (Why?)
Modulus:
Your modulus must be at least as big as the number of letters in the alphabet. If you start with A=2, you need two more numbers (modulus at least 28).
Encoding number:
For addition codes, you can choose any number. For multiplication codes, your encoding numbication codes, your encoding number must have no prime factors in common with the modulus. Otherwise, it will be impossible to decode your message. For example, try encoding a message choosing A=0, modulus=26, and encoding number 13. Note that 13 and 26 both have the prime factor 13.
How to decode
The encoding/decoding procedure is based on
clock arithmetic
. This is how the message is encoded if you're using an addition code with A=0:
Each letter is converted to a number, with A=0, B=1, through Z=25.
A
B
C
D
E
F
G
H
I
J
K
L
M
0
1
2
3
4
5
6
7
8
9
10
11
12
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
13
14
15
16
17
18
19
20
21
22
23
24
25
These numbers (0 through 25) are thought of as numbers on a clock, where the number you have for the "modulus" is the number of hours on the clock. If you use the 26 that is already typed in, you have a 26-hour clock, where 0 is the nhour clock, where 0 is the number after 25.
Each letter of the message (now a number) is encoded by adding the encoding number you chose. Addition is on the clock. For example, if your encoding number is 5 and the modulus is 26, then 0 gets encoded as 5, 17 gets encoded as 22, and 25 gets encoded as 4 (remember that the number after 25 is 0: 25+1 = 0).
So, working backwards through the encoding instructions, here is how to decode.
Each number of the encoded message is decoded by subtracting the encoding number you chose. Remember that subtraction is on the clock. For example, if your encoding number is 5, then 7 gets decoded as 2, 22 gets decoded as 17, and 3 gets decoded as 24 (remember that the number before 0 is 25: 0-1 = 25, so 3-5 = -2 = 24).
Each number is converted back to a letter, with A=0, B=1, through Z=25.
If you used a multiplication code, each number gets multiplied by, instead of added to, the encoding number. The inverse operation to multiplication is division, so to decode the message, the recipient has to divide by the decoding number. But this turns out to be tricky on a clock. It's impossible if your encoding number and the modulus have a prime factor in common. If they don't have any primes in common, you divide by multiplying by the multiplicative inverse. This is the number so that encoding number x its inverse = 1 on the clock. One way to find it is trial and error. There are better ways; check back later for details.