List of utility methods to do Hex Calculate
String | toHexaString(byte[] data) to Hexa String return toHexaString(data, 0, -1);
|
String | toHexaString(int value) Returns a string representation of the integer argument as an unsigned integer in base 16. return Integer.toHexString(value);
|
String | toHexByte(byte b) to Hex Byte return String.format("0x%02X", b & 0xFF); |
void | toHexByte(byte b, StringBuffer sb) to Hex Byte int n1 = (b & 0xF0) >> 4; int n2 = (b & 0xF); sb.append((char) (n1 < 10 ? n1 + '0' : (n1 - 10) + 'A')); sb.append((char) (n2 < 10 ? n2 + '0' : (n2 - 10) + 'A')); |
int | toHexByte(final char ch1, final char ch2) to Hex Byte final int i1 = hexDigit(ch1); final int i2 = hexDigit(ch2); if (i1 >= 0 && i2 >= 0) { return (i1 << 4) | i2; return -1; |
String | toHexByte(int bite) Converts a byte to a hex String. return String.valueOf(toHexNibble(bite >> 4)) + toHexNibble(bite);
|
String | toHexByte(int i) Converts an integer to a 2-digit hexadecimal string. assert (i >= 0 && i < 256); String s = Integer.toString(i, 16); if (s.length() < 2) return "0" + s; return s; |
byte[] | toHexByteArray(final byte[] buffer) Generate a byte array that is a hex representation of a given byte array. return toHexByteArray(buffer, 0, buffer.length);
|
String | toHexBytes(byte[] bytes) to Hex Bytes StringBuilder buffer = new StringBuilder(); for (byte b : bytes) { buffer.append(String.format(" %02x", b)); return buffer.toString(); |
char[] | toHexBytes(byte[] data) to Hex Bytes if (data == null) return null; int len = data.length; char[] out = new char[len << 1]; for (int i = 0, j = 0; i < len; i++) { out[j++] = hexDigits[(0xF0 & data[i]) >>> 4]; out[j++] = hexDigits[0x0F & data[i]]; return out; |