K i~TddlmZddlZddlZddlZddlZddgZdZd dZd dZ d dZ y) ) annotationsN accept_key apply_maskz$258EAFA5-E914-47DA-95CA-C5AB0DC85B11crtjd}tj|j S)zB Generate a random key for the Sec-WebSocket-Key header. )secrets token_bytesbase64 b64encodedecode)keys V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/websockets/utils.py generate_keyrs.   b !C   C ' ' ))ctj|tzjj }t j |jS)z Compute the value of the Sec-WebSocket-Accept header. Args: key: Value of the Sec-WebSocket-Key header. )hashlibsha1GUIDencodedigestr r r )r rs rrrsB <<t++- . 5 5 7D   D ! ( ( **rcbt|dk7r tdtj|tj }|t|dzz|dt|dzz}tj|tj }||z j t|tj S)z Apply masking to the data of a WebSocket message. Args: data: Data to mask. mask: 4-bytes mask. zmask must contain 4 bytesN)len ValueErrorint from_bytessys byteorderto_bytes)datamaskdata_int mask_repeatedmask_ints rrr$s 4yA~455~~dCMM2HCIN+d?SY].CCM~~mS]];H x  ) )#d)S]] CCr)returnstr)r r&r%r&)r bytesr!r'r%r') __future__rr rrr__all__rrrrrrr+s7"    &.* +Dr