Proj X10: Two-Time Pad (15 pts)

What You Need

Any computer with Python 2.7.

Background

One-time pads are very secure, but not if you use the pad more than once. Russia made this error during World War II and it led to complete compromise of their encryption system, as detailed in this book.


Using a One-Time Pad

Let's use this keystring:
Unbreakable awesome secret secure system
To encrypt this message:
Four score and seven
This Python code does the encryption:
key = "Unbreakable awesome secret secure system"
plaintext = "Four score and seven"

i = 0
ciphertext = ""
for p in plaintext:
  ip = ord(p)
  k = key[i]
  ik = ord(k)
  inew = ip ^ ik
  ciphertext += chr(inew)
  print p, hex(ip), k, hex(ik), hex(inew)
  i += 1
print ciphertext.encode("hex")
This program encrypts the string, as shown below.

Here's a shorter program that does the same thing, with less output:

key = "Unbreakable awesome secret secure system"
plaintext = "Four score and seven"

i = 0
ciphertext = ""
for p in plaintext:
  ciphertext += chr( ord(p) ^ ord(key[i]) )
  i += 1
print ciphertext.encode("hex")
This program encrypts the string, as shown below.

Decrypting uses the same operation, since XOR reverses itself:

key = "Unbreakable awesome secret secure system"
ciphertext = "130117004512080e100945410f1345000a1b004e".decode("hex")

i = 0
plaintext = ""
for p in ciphertext:
  plaintext += chr( ord(p) ^ ord(key[i]) )
  i += 1
print plaintext
This string, is decrypted, as shown below.


Challenge X10.1: Using a Known Key (5 pts)

Use this key:
Wow, what a great key!
Decrypt this ciphertext:
0e20220c67383c413d7440
Enter the plaintext into the form below to record your success.

X10.1: Recording Your Success (5 pts)

Use the form below to record your score in Canvas.
Name or Email:
Plaintext:

Challenge X10.2: Partial Key (10 pts)

The key starts with:
The
Both these ciphertexts were encrypted with the same key:
1a0d134503550e0a1d4542071f56
0d0710071d19490d0e5607004f00074e47
To break this, start with a guess at the key, like this:
The................................
This shows the first three letters of the two plaintext messages, as shown below.

From the partial plaintexts, you can guess another letter or two, and use those letters to extend the key. Continue adding one or two letters at a time until you get the whole plaintext.

Enter either plaintext message into the form below to record your success.


X10.2: Recording Your Success (10 pts)

Use the form below to record your score in Canvas.
Name or Email:
Plaintext:

Posted 1-15-19