def xor_bytes(input_bytes, key_bytes):
    """XOR input bytes, repeating the XOR key as necessary."""
    result = []
    for i, inb in enumerate(input_bytes):
        result.append(inb ^ key_bytes[i % len(key_bytes)])
    return bytes(result)
