List of utility methods to do Hex Calculate
String | toHexString(final byte b) Converts a byte into its hexadecimal representation, padding with a leading zero to get an even number of characters. String hexString = Integer.toHexString(b & 0xFF); if (hexString.length() % 2 != 0) { hexString = "0" + hexString; return hexString; |
String | toHexString(final byte b) to Hex String return toHexString(toByteArray(b));
|
String | toHexString(final byte hex) to Hex String return "0x" + Integer.toHexString(hex & 0x000000FF); |
String | toHexString(final byte value) Returns a unsigned hex String of the byte value.
String result = Integer.toHexString(toUnsigned(value)).toUpperCase(); if (result.length() == 1) { result = "0x0" + result; } else { result = "0x" + result; return result; |
String | toHexString(final byte[] arr) to Hex String final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Integer.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Integer.toHexString(arr[i])); buffer.append(']'); return buffer.toString(); |
String | toHexString(final byte[] array) to Hex String return toStringHex(array, 0, array.length);
|
String | toHexString(final byte[] b) Converts a byte array to a hex string representing it. final StringBuilder sb = new StringBuilder(); for (final byte element : b) { sb.append(hexChar[(element & 0xf0) >>> 4]); sb.append(hexChar[element & 0x0f]); return sb.toString(); |
String | toHexString(final byte[] bs) to Hex String final int len; if (bs != null && (len = bs.length) != 0) { final char[] cs = new char[len << 1]; final char[] myDigits = DIGITS; byte b; for (int i = 0, j = 0; i < len; i++) { cs[j++] = myDigits[((b = bs[i]) >>> 4) & 0xF]; cs[j++] = myDigits[b & 0xF]; ... |
String | toHexString(final byte[] bs, final char[] myDigits) to Hex String final int len; if (bs == null || (len = bs.length) == 0) { return null; final char[] cs = new char[len << 1]; byte b; for (int i = 0, j = 0; i < len; i++) { cs[j++] = myDigits[((b = bs[i]) >>> 4) & 0xF]; ... |
String | toHexString(final byte[] buffer) Converts an array of bytes into an hex string. final char[] charBuffer = new char[buffer.length * 2]; for (int i = 0; i < buffer.length; ++i) { charBuffer[i * 2] = HEX_DIGITS[(buffer[i] >> BITS_SIZE_OF_NIBBLE) & INT_BYTE_LOW_NIBBLE_MASK]; charBuffer[i * 2 + 1] = HEX_DIGITS[buffer[i] & INT_BYTE_LOW_NIBBLE_MASK]; return new String(charBuffer); |