To encrypt this message:
Unbreakable awesome secret secure system
This Python code does the encryption:
Four score and seven
This program encrypts the string, as shown below.
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("ascii").hex())
Decrypting uses the same operation, since XOR reverses itself:
This string, is decrypted, as shown below.
key = "Unbreakable awesome secret secure system" ciphertext = bytes.fromhex("130117004512080e100945410f1345000a1b004e") i = 0 plaintext = "" for c in ciphertext: k = key[i] ik = ord(k) ip = c ^ ik p = chr(ip) print(c, k, ik, ip, p) plaintext += p i += 1 print(plaintext)
C 105.1: Using a Known Key (5 pts)Use this key:Decrypt this ciphertext:
Wow, what a great key!The plaintext is the flag.
C 105.2: Crib Drag (15 pts)The key starts with:Both these ciphertexts were encrypted with the same key:
TheTo break this, start with a guess at the key, like this:
1a0d134503550e0a1d4542071f56 0d0710071d19490d0e5607004f00074e47This 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. This is called the
crib drag attack. Submit either of the plaintext messages as the flag.
C 105.3: Crib Drag (15 pts)Both these ciphertexts were encrypted with the same key:One of the plaintext messages contains the flag.
C 105.4: Crib Drag (50 pts)Both these ciphertexts were encrypted with the same key:One of the plaintext messages contains the flag.