
    tni                    b    d dl mZ d dlZd dlZd dlZd dlZddlmZ ddgZdZ	dd
Z
ddZddZdS )    )annotationsN   )	BytesLike
accept_key
apply_maskz$258EAFA5-E914-47DA-95CA-C5AB0DC85B11returnstrc                 v    t          j        d          } t          j        |                                           S )zB
    Generate a random key for the Sec-WebSocket-Key header.

       )secretstoken_bytesbase64	b64encodedecode)keys    M/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/websockets/utils.pygenerate_keyr      s1    
 
b
!
!CC  '')))    r   c                    t          j        | t          z                                                                             }t          j        |                                          S )z
    Compute the value of the Sec-WebSocket-Accept header.

    Args:
        key: Value of the Sec-WebSocket-Key header.

    )hashlibsha1GUIDencodedigestr   r   r   )r   r   s     r   r   r      sL     <t++--..5577DD!!((***r   datar   maskbytes | bytearraybytesc                   t          |          dk    rt          d          t                              | t          j                  }|t          |           dz  z  |dt          |           dz           z   }t                              |t          j                  }||z                      t          |           t          j                  S )z
    Apply masking to the data of a WebSocket message.

    Args:
        data: Data to mask.
        mask: 4-bytes mask.

       zmask must contain 4 bytesN)len
ValueErrorint
from_bytessys	byteorderto_bytes)r   r   data_intmask_repeatedmask_ints        r   r   r   &   s     4yyA~~4555~~dCM22HCIIN+d?SYY]?.CCM~~mS];;Hx))#d))S]CCCr   )r   r	   )r   r	   r   r	   )r   r   r   r   r   r   )
__future__r   r   r   r   r%   typingr   __all__r   r   r   r    r   r   <module>r/      s    " " " " " "    



       
& .* * * *	+ 	+ 	+ 	+D D D D D Dr   