Two Time Pad


surely using it just one more time is fine right?

Challenge Script:
import os

PUBLIC_MESSAGE = b"Hello! This is a real message. However, obtaining this won't give you anything; you need to find the secret message"
SECRET_MESSAGE = b"This is a fake message. The output produced is by running this script with the real message."

one_time_pad = os.urandom(len(PUBLIC_MESSAGE)) # generates a completely random key to be used in the XOR cipher

def xor(key, plaintext): # performs a XOR operation on the key and the plaintext
    return bytes([keybyte ^ ptbyte for keybyte, ptbyte in zip(key, plaintext)])

print(xor(one_time_pad, PUBLIC_MESSAGE).hex()) # outputs the result of xor(one_time_pad, public_message) as a hex string
print(xor(one_time_pad, SECRET_MESSAGE).hex())
Output:
bb3652a6ccc9729d566062032f38015a24c66639f8ed9e0ddf97183c08584cf845a5a7fa76d0ec819f2628db218430fb29b810d46f9997b1a20663801134a0e44134ef0972842dffae55cd5913b8f922a429b921184062d19262c94eaf81cbbb8586e0615211f4f7409a2a40ec0804e3b7fde9
b03c50add18926bc5268654a2925521b6bda233efda39701c283592f051f1f9059b7a1fe76d6e0cc95372fdb2f8f77b51af0019c6784c4b1a81a648d5e26e9fc4171f24673cb6ce2a243c85909ffab71fd028940226d27e5f758e7229da1e08c