Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-141

One-Time Pad XOR

Problem

Encrypt (or decrypt) a bit list with a one-time pad by XORing it elementwise with a key of the same length. XOR is its own inverse, so the same function recovers the plaintext.

Hint

A pad used twice is no longer a one-time pad.

Test cases

case 1
in: [[0,1,1],[1,1,0]]
expected: [1,0,1]
case 2
in: [[1,1],[0,0]]
expected: [1,1]
case 3
in: [[0],[1]]
expected: [1]
case 4
in: [[1,0,0,1],[1,1,1,1]]
expected: [0,1,1,0]
Starter codePython
def otp_xor(bits, key):
    # Your code here
    pass

4 test cases · run your code against them in the editor