All problems
XOR Repeat Key
Problem
Encrypt (or decrypt) a list of byte values with a repeating XOR key: out[i] = data[i] ^ key[i % len(key)]. Return the resulting byte list.
Hint
Repeating-key XOR is symmetric, so the same call decrypts.
Test cases
case 1
in: [[1,2,3],[1]]
expected: [0,3,2]
case 2
in: [[1,2,3],[1,2]]
expected: [0,0,2]
case 3
in: [[0,0,0],[5]]
expected: [5,5,5]
case 4
in: [[255,0],[15,240]]
expected: [240,240]
Starter codePython
def xor_repeat_key(data, key):
# Your code here
pass4 test cases · run your code against them in the editor