code: static byte[] mask(byte[] maskingKey, byte[] payload)
      {
          if (maskingKey == null || maskingKey.length < 4 || payload == null)
          {
              return payload;
          }
  
          for (int i = 0; i < payload.length; ++i)
          {
              payload[i] ^= maskingKey[i % 4];
          }
  
          return payload;
      }
docs: Mask/unmask payload.
  
  <p>
  The logic of masking/unmasking is described in "<a href=
  "http://tools.ietf.org/html/rfc6455#section-5.3">5.3.
  Client-to-Server Masking</a>" in RFC 6455.
  </p>
  
  @param maskingKey
  The masking key. If {@code null} is given or the length
  of the masking key is less than 4, nothing is performed.
  
  @param payload
  Payload to be masked/unmasked.
  
  @return
  {@code payload}.
  
  @see <a href="http://tools.ietf.org/html/rfc6455#section-5.3">5.3. Client-to-Server Masking</a>