Mod Tutorial

(a.k.a. Math for Dummies) by Diandra
A printable word document here.

Concepts

       Mod System

To understand how to decrypt codes based on a mod system, it's necessary to understand the concept. Here's the concept, by example.

In the US, we often will express a time as 4 pm; in the military, its equivalent is 16:00. This could be explained as being based on mod 12 because our clock has 12 numerals.

To ďdecodeĒ 16:00 to 4pm, we begin at the 12 and count clockwise 16 places to end up at the 4. We use the pm notation to denote that weíve already been around the clock once that day.

So you could say that 16 = 4 in mod 12.

Rather than counting around the clock, we can just take the original number (16), subtract the mod we are using (12), and get the remainder (4).

Thatís pretty straightforward. Mods are very easy to calculate when the interval between each number is one place, so itís not very effective for sending coded messages.
 

    Intervals


Consider this: You are a spy. You want to meet with your contact in the middle of the night. The only way you can reach your contact is to post the time of your meeting in a public place. You donít want others who may see your message (the enemy) to attend your meeting. So youíve agreed with your contact to send messages based on an interval of two.

Using this method, midnight is at the 12 position on the clock (as usual), and 1am would skip to the 2 position. 2am would be written as 4, etc.
So, if you wanted to meet at 3am, youíd say the meeting was at 6, and your enemy who intercepted your message would show up at 6am, after youíd be long gone.

3, using mod 12, with an interval of 2, would be 6. (3 x 2 = 6) In this example, we didnít go ďaround the clockĒ, so to speak, making it relatively easy to decode. You can see, however, if your meeting was scheduled for later in the day, or if you had agreed to an interval larger than two, things could become a bit more complex. (Weíll delve into that in the next section.)

Applications

     English Alphabet

The English alphabet is based on 26 characters, A-Z. Like our clock, which started at midnight, weíll start numbering the letters with zero as our first placeholder.

0     a
1     b
2     c
3     d
4     e
5     f
6     g
7     h
8     i
9     j
10   k
11   l
12   m
13   n
14   o
15   p
16   q
17   r
18   s
19   t
20   u
21   v
22   w
23   x
24   y
25   z

If we count all of the letters, weíll find that the alphabet is naturally a mod 26 system, even though our numbers only reach 25. This is because we began numbering at zero.

Now, letís work with English in mod 28. (label 0 Ė 27)

0   a
1   b
2   c
3   d
4   e
5   f
6   g
7   h
8   i
9   j
10 k
11 l
12 m
13 n
14 o
15 p
16 q
17 r
18 s
19 t
20 u
21 v
22 w
23 x
24 y
25 z
26
27

You can see from the chart above that with an interval of 1, breaking a code would be easy in mod 28. It makes no difference what mod it is, as long as itís mod 26 or higher. Our alphabet remains unchanged.

19 7 8 18   8 18   19 14 14   4 0 18 24
 
 

What would happen with, say, an interval of 3? How the heck do we create a chart like that? Try it on your own before you turn the page.

(Hint: Keep in mind our clock example.)
Mod 28, interval 3

0   a
1   t
2   k
3   b
4   u
5   l
6   c
7   v
8   m
9   d
10 w
11 n
12 e
13 x
14 o
15 f
16 y
17 p
18 g
19 z
20 q
21 h
22
23 r
24 i
25
26 s
27 j

As in our clock example, when we reach the last number, we just start over at the first number. Notice that when the chart is complete, we still have two numbers without associated letters. Thatís because we only have 26 characters to work with, and itís a mod 28 system. This is okay. However, if the message we were trying to decode had a 22 or a 25 in it, we would know instantly that it was not created with mod 28, interval 3 if the message was supposed to be in English! Then we would need to try some other intervals as long as we knew it was a mod 28 code.
 
 

Before turning the page, create a mod 28 chart with an interval of 2. What happens? What does this tell us?
 

Decryption Principles

    Ruling Out Intervals


Looking at your mod 28, interval 2 chart, youíll find that some numbers can represent more than one letter. Generally, this would cause that interval to be considered not a valid solution.* The way to rule out other intervals is to check if the mod youíre using is divisible by the interval, or by a factor of the interval. In this case, because our mod happens to be an even number, an interval of 2, or multiples of 2 (such as 4, 6, 8, etc.), will produce solutions with some numbers resolving to more than one letter.

Another way to rule out improbable intervals can be done. For example, if we were given a code of 9 0 1 8 27, without creating a chart, how do we know itís not using an interval of 1? (The answer should be fairly obvious, but if itís not, peek at the chart on page 3.) We can also tell itís not mod 27. Keep in mind that the interval cannot exceed the mod, because solutions would just repeat those of earlier intervals.

With our code of 9 0 1 8 27, assuming mod 28, we can rule out intervals of:
 

interval  reason

1 visually, because the code has a 27 in it
2 28 is divisible by 2
4 28 is divisible by 4
6 factors to 2*3, and 28 is divisible by 2
7 28 is divisible by 7
8 factors to 2*2*2, and 28 is divisible by 2
 10 factors to 2*5, and 28 is divisible by 2
12 factors to 2*2*3, and 28 is divisible by 2
14 28 is divisible by 14
16 factors to 2*2*2*2, and 28 is divisible by 2
18 factors to 2*3*3, and 28 is divisible by 2
20 factors to 2*2*5, and 28 is divisible by 2
21 factors to 3*7, and 28 is divisible by 7
22 factors to 2*11, and 28 is divisible by 2
24 factors to 2*2*2*3, and 28 is divisible by 2
26 factors to 2*13, and 28 is divisible by 2
28 28 is divisible by 28

The intervals left to test are 3, 5, 9, 11, 13, 15, 17, 19, 23, 25, & 27
_____________________
* We saw multiple letter codes used in Chasing the Wish where it did appear to be a valid solution and players were required to figure out which letters were in- or ex-cluded.

    Calculations

Making all of these charts can be tedious. Well, there is an easier way.

Below is the Alphabet Chart. To figure out the value for a specific interval, take the corresponding number from the Alphabet Chart, multiply by the interval, then calculate the mod. (Mod function keys are included on scientific calculators, including the one found in Windows. Just open the calculator, click View, and change to Scientific.)

To find the value for W, Mod 28, with an interval of 3, click:

2 2 * 3 =

The display will read 66. Then click:

Mod 2 8 =

The display should read 10, which is verified by the interval 3 chart we did on page 4.

Alphabet Chart (same as interval of 1)
0   a
1   b
2   c
3   d
4   e
5   f
6   g
7   h
8   i
9   j
10 k
11 l
12 m
13 n
14 o
15 p
16 q
17 r
18 s
19 t
20 u
21 v
22 w
23 x
24 y
25 z
Congratulations! Now you have all of the skills necessary to finish decrypting our code. Hopefully, when youíre done, you wonít be 9 0 1 8 27 than you were when you began!

Diandra

More hints for this code:

0 = A for all possible intervals.
There is probably at least one other vowel in the code.
Decode vowels first for all probable intervals. If you get a hit in the code, then begin calculating possible consonants. This may save a lot of time!