Java Utililty Methods Hex Calculate

List of utility methods to do Hex Calculate

Description

The list of methods to do Hex Calculate are organized into topic(s).

Method

StringtoHex(byte[] bytes)
to Hex
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
    sb.append(toHex(b >>> 4));
    sb.append(toHex(b));
return sb.toString();
StringtoHex(byte[] bytes)
Returns the hex representation of the byte array.
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
    if ((bytes[i] & 0xff) < 0x10) {
        sb.append('0');
    sb.append(Long.toString(bytes[i] & 0xff, 16));
return sb.toString();
...
StringtoHex(byte[] bytes)
Converts an array of bytes into a single hex number.
char[] chars = new char[bytes.length * 2];
for (int i = 0; i < bytes.length; ++i) {
    int j = i * 2;
    for (int k = 0; k < 2; ++k) {
        int byte_i = bytes[i];
        if (byte_i < 0)
            byte_i = 128 - byte_i;
        int hb = (byte_i >> ((1 - k) * 4)) % 16;
...
StringtoHex(byte[] bytes)
Converts the byte array into a hexadecimal string.
final char[] out = new char[bytes.length * 2];
for (int i = 0; i < bytes.length; i++) {
    out[2 * i] = HEX_DIGITS[bytes[i] < 0 ? 8 + (bytes[i] + 128) / 16 : bytes[i] / 16]; 
    out[2 * i + 1] = HEX_DIGITS[bytes[i] < 0 ? (bytes[i] + 128) % 16 : bytes[i] % 16];
return new String(out); 
StringtoHex(byte[] bytes)
Convert provided byte array to hex string representation in format AA:FF:47:11.
if (bytes == null) {
    return "";
char[] hexChars = new char[bytes.length * 3];
for (int j = 0; j < bytes.length; j++) {
    int v = bytes[j] & 0xFF;
    hexChars[j * 3] = HEX_ALPHAPET[v >>> 4];
    hexChars[j * 3 + 1] = HEX_ALPHAPET[v & 0x0F];
...
StringtoHex(byte[] bytes)
to Hex
StringBuffer buffer = new StringBuffer();
for (byte b : bytes) {
    int index = b & 0xFF;
    buffer.append(HexDigits[index]);
return buffer.toString();
StringtoHex(byte[] bytes)
Encodes an array of bytes as hex symbols.
return toHex(bytes, null);
StringtoHex(byte[] bytes)
to Hex
if (bytes == null) {
    return "";
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte aByte : bytes) {
    int b = aByte & 0xFF;
    sb.append(hexChars.charAt(b >> 4));
    sb.append(hexChars.charAt(b & 15));
...
StringtoHex(byte[] bytes)
to Hex
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);
StringtoHex(byte[] bytes)
to Hex
return toHex(bytes, 0, bytes.length);