
    :"ri                    `    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y)    )annotationsN   )	BytesLike
accept_key
apply_maskz$258EAFA5-E914-47DA-95CA-C5AB0DC85B11c                 r    t        j                  d      } t        j                  |       j	                         S )zB
    Generate a random key for the Sec-WebSocket-Key header.

       )secretstoken_bytesbase64	b64encodedecode)keys    X/var/www/fortnox.pascalinesoft.com/venv/lib/python3.12/site-packages/websockets/utils.pygenerate_keyr      s.    
 

b
!CC ''))    c                    t        j                  | t        z   j                               j	                         }t        j                  |      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      sB     <<t++-.557DD!((**r   c                b   t        |      dk7  rt        d      t        j                  | t        j
                        }|t        |       dz  z  |dt        |       dz   z   }t        j                  |t        j
                        }||z  j                  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)datamaskdata_intmask_repeatedmask_ints        r   r   r   &   s     4yA~455~~dCMM2HCIN+d?SY].CCM~~mS]];Hx))#d)S]]CCr   )returnstr)r   r(   r'   r(   )r"   r   r#   zbytes | bytearrayr'   bytes)
__future__r   r   r   r
   r   typingr   __all__r   r   r   r    r   r   <module>r.      s:    "    
  
& .*	+Dr   