code: public static void unmask(WrappedByteBuffer buf, int mask) {
          byte b;
          int remainder = buf.remaining() % 4;
          int remaining = buf.remaining() - remainder;
          int end = remaining + buf.position();
  
          // xor a 32bit word at a time as long as possible
          while (buf.position() < end) {
              int plaintext = buf.getIntAt(buf.position()) ^ mask;
              buf.putInt(plaintext);
          }
  
          // xor the remaining 3, 2, or 1 bytes
          switch (remainder) {
          case 3:
              b = (byte) (buf.getAt(buf.position()) ^ ((mask >> 24) & 0xff));
              buf.put(b);
              b = (byte) (buf.getAt(buf.position()) ^ ((mask >> 16) & 0xff));
              buf.put(b);
              b = (byte) (buf.getAt(buf.position()) ^ ((mask >> 8) & 0xff));
              buf.put(b);
              break;
          case 2:
              b = (byte) (buf.getAt(buf.position()) ^ ((mask >> 24) & 0xff));
              buf.put(b);
              b = (byte) (buf.getAt(buf.position()) ^ ((mask >> 16) & 0xff));
              buf.put(b);
              break;
          case 1:
              b = (byte) (buf.getAt(buf.position()) ^ (mask >> 24));
              buf.put(b);
              break;
          case 0:
          default:
                  break;
          }
          //buf.position(start);
      }
docs: Performs an in-situ unmasking of the readable buf bytes.
  Preserves the position of the buffer whilst unmasking all the readable bytes,
  such that the unmasked bytes will be readable after this invocation.
  
  @param buf   the buffer containing readable bytes to be unmasked.
  @param mask  the mask to apply against the readable bytes of buffer.