CSE 207B, Fall 2025
Homework 1: Many-time pad

You are given the ciphertext file here. Each line of the ascii plaintext has been encrypted by xoring with the same randomly generated key pad, then encoded in hex. Your task is to decrypt as much of it as possible. You should at least be able to get the entire last line.

Please submit your code and writeup to Gradescope. You may discuss this assignment in small groups with classmates, but please code and write up your solutions yourself. Please credit any collaborators you discussed with and any references you used.

Start early! This assignment will take longer than you think.

Submission requirements

Submission requirements:

Additional material

For reference, the ciphertext was generated using the following Python 3 program, adapted from Dan Boneh.
import os

MSGS = open("hw1-message.txt").readlines()

def bytexor(a, b):     # xor two byte arrays (trims the longer input)
    return bytes([x ^ y for (x,y) in zip (a,b)])

def random(size=16):
    return os.urandom(size)

def encrypt(key, msg):
    c = bytexor(key, msg)
    print(c.hex())
    return c

def main():
    key = random(1024)
    ciphertexts = [encrypt(key, msg.encode('utf-8')) for msg in MSGS]
    return ciphertexts

if __name__=='__main__':
    main()