Create an hexadecimal dump of the given buffer.
199775
public static void dumpHex(StringBuilder s, ByteBuffer buffer) {
		int savePos = buffer.position();
		int line = 0;
		while (buffer.hasRemaining()) {
			s.append(StringUtil.encodeHexaPadding(16L * line)).append(' ');
			int l = buffer.remaining() >= 16 ? 16 : buffer.remaining();
			byte[] b = new byte[l];
			buffer.get(b);
			for (int i = 0; i < 16; ++i) {
				if (b.length <= i) s.append("   ");
				else s.append(StringUtil.encodeHexa(b[i])).append(' ');
			}
			s.append("  ");
			for (int i = 0; i < 16; ++i) {
				if (b.length <= i) s.append(' ');
				else {
					char c = (char)(b[i] & 0xFF);
					if (c < 0x20 || c > 0x7F) c = '.';
					s.append(c);
				}
			}
			s.append("\r\n");
			line++;
		}
		buffer.position(savePos);
	}
809811
function bnToBuffer( bn ) {
  var hex = bn.toString( 16 )
  hex = hex.length % 2 === 1 ? '0' + hex : hex
  return Buffer.from( hex, 'hex' )
}
105525
public static String toHex(byte b) {
      StringBuilder sb = new StringBuilder();
      appendByteAsHex(sb, b);
      return sb.toString();
   }
638693
public static String toHex(byte[] b) {
        char[] buf = new char[b.length * 2];
        int j = 0;
        int k;

        for (byte aB : b) {
            k = aB;
            buf[j++] = HEX[(k >>> 4) & 0x0F];
            buf[j++] = HEX[k & 0x0F];
        }
        return new String(buf);
    }
201393
private static String bytesToHex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int i = 0; i < bytes.length; i++) {
            int v = bytes[i] & 0xFF;
            hexChars[i * 2] = hexArray[v >>> 4];
            hexChars[i * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
351909
static public String getHexDump(byte[] data, int length) {
        // boundary checks....
        if (null == data || 0 > length) {
            return null;
        }
        // if we have less than the target amount, just print what we have
        if (data.length < length) {
            length = data.length;
        }
        int numlines = (length / 16) + (((length % 16) > 0) ? 1 : 0);
        StringBuilder buffer = new StringBuilder(73 * numlines);
        for (int i = 0, line = 0; line < numlines; line++, i += 16) {
            buffer = formatLineId(buffer, i);
            buffer.append(": ");
            // format the first 8 bytes as hex data
            buffer = formatHexData(buffer, data, i);
            buffer.append("  ");
            // format the second 8 bytes as hex data
            buffer = formatHexData(buffer, data, i + 8);
            buffer.append("  ");
            // now print the ascii version, filtering out non-ascii chars
            buffer = formatTextData(buffer, data, i);
            buffer.append('\n');
        }
        return buffer.toString();
    }
139795
public static byte[] fromHexByteArray(final byte[] buffer)
    {
        final byte[] outputBuffer = new byte[buffer.length >> 1];

        for (int i = 0; i < buffer.length; i += 2)
        {
            final int hi = FROM_HEX_DIGIT_TABLE[buffer[i]] << 4;
            final int lo = FROM_HEX_DIGIT_TABLE[buffer[i + 1]]; // lgtm [java/index-out-of-bounds]
            outputBuffer[i >> 1] = (byte)(hi | lo);
        }

        return outputBuffer;
    }
383876
private static String byteToHexString(byte[] bytes)
  {
    final char[] hexArray = "0123456789ABCDEF".toCharArray();
    char[] hexChars = new char[bytes.length * 2];
    for (int j = 0; j < bytes.length; j++)
    {
      int v = bytes[j] & 0xFF;
      hexChars[j * 2] = hexArray[v >>> 4];
      hexChars[j * 2 + 1] = hexArray[v & 0x0F];
    }
    return new String(hexChars);
  }
49115
def _encode_buffer(string, f):
	""""""
	if isinstance(string, str):
		string = string.encode()
	f.write(str(len(string)).encode())
	f.write(_TYPE_SEP)
	f.write(string)
217289
public static String toHexString(byte[] b, int offset, int length) {
        StringBuilder buf = new StringBuilder();
        for (int i = offset; i < offset + length; i++) {
            int bi = 0xff & b[i];
            int c = '0' + (bi / 16) % 16;
            if (c > '9') {
                c = 'A' + (c - '0' - 10);
            }
            buf.append((char) c);
            c = '0' + bi % 16;
            if (c > '9') {
                c = 'a' + (c - '0' - 10);
            }
            buf.append((char) c);
        }
        return buf.toString();
    }
188706
function fromUtf8(stringValue) {
  const str = new Buffer(stringValue, 'utf8');

  return `0x${padToEven(str.toString('hex')).replace(/^0+|0+$/g, '')}`;
}
799030
async def dump_uint(writer, n, width):
    
    buffer = _UINT_BUFFER
    for _ in range(width):
        buffer[0] = n & 0xff
        await writer.awrite(buffer)
        n >>= 8
156346
def hexdump(src, length=8):
    
    if not src:
        return str(src)
    src = input_validate_str(src, 'src')
    offset = 0
    result = ''
    for this in group(src, length):
        hex_s = ' '.join(["%02x" % ord(x) for x in this])
        result += "%04X   %s\n" % (offset, hex_s)
        offset += length
    return result
880687
def from_hex(cls, value):
        """"""
        if len(value) == 8:
            return cls(int(value, 16))
        elif len(value) == 32:
            return cls(int(value, 16))
        else:
            raise ValueError('%r: invalid hexadecimal notation' % (value,))
658251
private static String byte2hex(byte[] bytes) {
        char[] hexChars =
                {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
                        'c', 'd', 'e', 'f'};

        StringBuffer sb = new StringBuffer();
        for (byte b : bytes) {
            sb.append(hexChars[b >> 4 & 0xf]);
            sb.append(hexChars[b & 0xf]);
        }

        return new String(sb);
    }
330227
public static String toHexString(ByteBuffer buffer) {
        if (buffer == null)
            return "null";
        return TypeUtils.toHexString(toArray(buffer));
    }
1083197
public static String toHexString(byte[] bytes, int start, int len) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < len; i++) {
            int b = bytes[start + i] & 0xFF;
            if (b < 16) buf.append('0');
            buf.append(Integer.toHexString(b));
        }
        return buf.toString();
    }