Compute the value of the Sec-WebSocket-Accept header. Args: key: Value of the Sec-WebSocket-Key header.
(key: str)
| 24 | |
| 25 | |
| 26 | def accept_key(key: str) -> str: |
| 27 | """ |
| 28 | Compute the value of the Sec-WebSocket-Accept header. |
| 29 | |
| 30 | Args: |
| 31 | key: Value of the Sec-WebSocket-Key header. |
| 32 | |
| 33 | """ |
| 34 | sha1 = hashlib.sha1((key + GUID).encode()).digest() |
| 35 | return base64.b64encode(sha1).decode() |
| 36 | |
| 37 | |
| 38 | def apply_mask(data: BytesLike, mask: bytes | bytearray) -> bytes: |
searching dependent graphs…