SSocketBrume
Workflows

Coding workflows · WebSocket payload unmasking

03
Built around your work

A concrete starting point

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.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

WebSocket payload unmasking

A concrete starting point
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.

AI coding workspace

Your next change starts here.

Get the Windows app ↗