public static String toHex(byte[] buf, int offset, int length) {
    if (buf == null) {
      return null;
    }

    char[] hex = new char[2 * length];
    for (int i = 0; i < length; i++) {
      int b = buf[i + offset] & 0xff;
      hex[2 * i] = HEX[b >>> 4];
      hex[2 * i + 1] = HEX[b & 0xf];
    }
    return new String(hex);
  }
Converts the byte array subset to a hex string.

@param buf the buffer to convert
@param offset the offset
@param length the length
@return the hex string
geode-core/src/main/java/org/apache/geode/internal/util/Hex.java