Cryptography 101 (post #2)

One Time Pads


Let's talk about them. One time pads were widely used throughout the 1900's. Especially, during WW1 and WW2 and even coming into The Cold War. In my last post, I kind of got a little too nerdy with the overview of the cryptography series but one time pads are really simple I promise.

First you get yourself a random set of letters.
There are 26 letters in the good ole' English alphabet and so every one of these letters represents a number between 0 and 25(the commas are just to clearly separate them).
For example:

MAMPE BVQDI JQORJ WRELZ


MAMPE = 12, 0, 12, 15, 4
BVQDI = 1, 21, 16, 3, 8
JQORJ = 9, 16, 14, 17, 9
WRELZ = 22, 17, 4, 11, 25

Now write the message you want to send someone with NO SPACES and NO PUNCTUATION

DELIV ERYAT NINET HIRTY

Now assign a number to each letter in the message you want to send. They, once again, must be between 0 and 25.

DELIV = 3, 4, 11, 8, 21
ERYAT = 4, 17, 24, 0, 19
NINET = 13, 4, 19, 7, 8
HIRTY = 7, 8, 17, 19, 24

Now add the numbers representing your random string of letters (this will be your key so don't let anyone see it)
and take the numbers representing your message
and add them together.
If the number goes over 25 start back from 0 and keep adding.
For example, 21 + 17 = 12 in the case of V + R

MAMPE BVQDI JQORJ WRELZ (random string) + DELIV ERYAT NINET HIRTY (message) =

PEXXZ FMODB WYBVC DZVEZ

PEXXZ = 15, 4, 23, 23, 25
FMODB = 5, 12, 14, 3, 1
WYBVC = 22, 24, 1, 21, 2
DZVEZ = 3, 25, 21, 4, 23

Anyone with the key could easily decrypt this cipher text (jumbled up confusing combination of letters), reason being the math is easy to reverse. The operation we just did together is called addition modulo 26

picture of addition modulo 26

Called such, because when you are adding numbers together and you get to the end (26) you just start back at 0 and keep adding the remainder, hence the term modulo. Now I want you to think a little. If we encrypted this thing with addition modulo 26, how would one decrypt it?........................................





Did you get it?




No it's fine, take your time.














How bout now?




























Exactly! Subtraction modulo 26 with the key would do the trick. Congratulations! You just got down your first encryption. As long as no one gets the key, they have no idea what or which key is correct, unless there's a pattern.

Wait!What do you mean by "unless there is a pattern"?

Well, let's say this key was generated by someone randomly jamming on the keyboard. Would that be truly random?

No, it wouldn't be. We could determined, based on how people type, which potential key is more likely.
So, if I was trying to decipher your message and there are two potential keys.

ASDF JKLP


ASDF = 0, 18, 3, 5
JKLP = 9, 10, 11, 15

RCDV DYUP


RCDV = 17, 2 , 3, 21
DYUP = 3, 24, 20, 15

If you randomly generated your key by typing I could determine based on how people type that ASDF JKLP is a much more likely key than RCDV DYUP because ASDF and JKLP are so close on the keyboard that you're much more likely to type those.

Then, how do we determine if something is "random" enough? We use entropy, and I'll save that for my next post.