docs: def generate_mask(cls, mask_key, data):
          """ Mask data.
  
          :Parameters:
              mask_key: byte string
                  4 byte string(byte), e.g. '\x10\xc6\xc4\x16'
              data: str
                  data to mask
  
          """
          # Masking of WebSocket traffic from client to server is required
          # because of the unlikely chance that malicious code could cause
          # some broken proxies to do the wrong thing and use this as an
          # attack of some kind. Nobody has proved that this could actually
          # happen, but since the fact that it could happen was reason enough
          # for browser vendors to get twitchy, masking was added to remove
          # the possibility of it being used as an attack.
          if data is None:
              data = ""
  
          data = bytearray(data, 'utf-8')
  
          _m = array.array("B", mask_key)
          _d = array.array("B", data)
  
          for i in range(len(_d)):
              _d[i] ^= _m[i % 4]
  
          return _d.tostring()