Cyber Security

Luke Hally

One time pad

August 1, 2021
Tags:

A one time pad is what’s known as a perfect cipher. Without the key it is uncrackable and can’t be brute forced. The penny dropped for me on how one time pads work this week, so I thought I would share how it works. 

I’m going to use the King James Bible (KJB) as a key. In a real world, high security example, we’d have a randomly generated key. This example will make it something you can try yourself. Let’s say I have a message:

“I have a message for you”, 19 characters long without spaces.

Encipher

HOW: Convert plain text to number (a,bc => 1,2,3), add to corresponding index of KJB, correct for overflow past 26, convert indexes into letters.

Suppose we use the KJB from the beginning and select the first 19 characters from it.

In the beginning God created the heaven and the earth. => INTHEBEGINNINGGODCR

Plain text9812251133191917561518251521
key91420852579141491477154318
added1822213010318122833151619132233291839
corrected18222141031812271516191322731813
Cipher textrvudjcrlbgopsmvgcrm

The enciphered message is: rvudjcrlbgopsmvgcrm 

Decipher

HOW: Convert cipher text to an array of indexes, subtract  corresponding index of KJB, convert indexes into letters.

Cipher text18222141031812271516191322731813
key91420852579141491477154318
minused981-451135-7-7175615-8-115-5
corrected9812251135191917561518251521
Plain textIHAVEAMESSAGEFORYOU

Deciphered message: ihaveamessageforyou

Reflection

There we go, we successfully enciphered and deciphered a message. In the real world, one time pads are used by spies to encrypt messages. They have a pad of randomly generated numbers that they can use as a key, once they have used a page of the pad, they burn it so it can never be reused – reusing keys weakens the encryption because patterns can appear in the cipher text.

If you want to send uncrackable ciphers to your friends or colleagues, you can find one time pad generators on the internet. Or if you want to send near uncrackable messages, just agree on a book with your friend. In either case, you have to include the key to the next message in your message. So at the end of your message, you could give the page and paragraph number to use as a key for the next message. If you don’t include the key, your friend won’t be able to decipher the message!

Recent posts