Open the context
Choose the project folder and name the files or behavior involved.
Unmask up to 1048576 WebSocket payload bytes with a four-byte key. Check empty input and repeated key positions, rejecting other types or key lengths and verifying the double-mask round trip.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def unmask_payload(data, mask):
if type(data) is not bytes or len(data) > 1048576:
raise ValueError("mask.payload")
if type(mask) is not bytes or len(mask) != 4:
raise ValueError("mask.key")
return bytes(value ^ mask[index % 4]
for index, value in enumerate(data))The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.