You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Enso-Bot/venv/Lib/site-packages/websockets/utils.py

15 lines
277 B
Python

4 years ago
import itertools
__all__ = ['apply_mask']
4 years ago
def apply_mask(data, mask):
4 years ago
"""
Apply masking to websocket message.
4 years ago
"""
if len(mask) != 4:
raise ValueError("mask must contain 4 bytes")
return bytes(b ^ m for b, m in zip(data, itertools.cycle(mask)))