List of utility methods to do Byte Array to Hex
String | bytesToHex(byte[] raw) bytes To Hex final StringBuilder hex = new StringBuilder(2 * raw.length); for (final byte b : raw) hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))); return hex.toString(); |
String | bytesToHex(byte[] raw) Converts bytes to a hex string. if (raw == null) { return null; final StringBuilder hex = new StringBuilder(2 * raw.length); for (final byte b : raw) { hex.append(Character.forDigit((b & 0xF0) >> 4, 16)).append(Character.forDigit((b & 0x0F), 16)); return hex.toString(); ... |
char[] | bytesToHex(byte[] raw) bytes To Hex int length = raw.length; char[] hex = new char[length * 2]; for (int i = 0; i < length; i++) { int value = (raw[i] + 256) % 256; int highIndex = value >> 4; int lowIndex = value & 0x0f; hex[i * 2 + 0] = kDigits[highIndex]; hex[i * 2 + 1] = kDigits[lowIndex]; ... |
String | bytesToHex(final byte[] b) Transforms byte to hex representation final StringBuilder buf = new StringBuilder(); for (final byte element : b) { buf.append(HEX_DIGITS[(element >> 4) & 0x0f]); buf.append(HEX_DIGITS[element & 0x0f]); return buf.toString(); |
String | bytesToHex(final byte[] bytes) Create a hexadecimal string representation of the given byte array. final StringBuilder sb = new StringBuilder(); for (final byte b : bytes) { sb.append(byteToHex(b)); return sb.toString(); |
String | bytesToHex(final byte[] bytes) Convert a byte array to a String of hex characters. if (bytes == null) return null; else { int length = bytes.length; String hexBytes = ""; for (int i = 0; i < length; i++) { if ((bytes[i] & 0xFF) < 16) { hexBytes += "0"; ... |
String | bytesToHex(final byte[] bytes) Converts a byte array into its hex string representation. StringBuilder builder = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { builder.append(HEXCHARS[(bytes[i] & 0xff) >>> 4]); builder.append(HEXCHARS[bytes[i] & 0xf]); builder.append(' '); return builder.toString(); |
String | bytesToHex(final byte[] bytes) Wandelt ein Byte-Array in eine hexadezimale Darstellung um StringBuilder stringBuilder = new StringBuilder(bytes.length * 2); for (byte b : bytes) { stringBuilder.append(Character.forDigit(0xF & (b >>> 4), 16)); stringBuilder.append(Character.forDigit(0xF & b, 16)); return stringBuilder.toString(); |
String | bytesToHex(final byte[] bytes, final boolean toLowerCase) Computes the Hex encoded input. char[] hexChars = new char[bytes.length * 2]; char[] hexArray = toLowerCase ? LOWER_HEX_ARRAY : UPPER_HEX_ARRAY; 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); ... |
String | bytesToHex(final byte[] bytes, final int position, final int length) Converts an array of bytes starting at position for length bytes to a hexadecimal string.
final char[] chars = new char[length * 2]; int charIndex = 0; for (int i = position; i < position + length; i++) { chars[charIndex++] = HEX[(bytes[i] & 0xf0) >>> 4]; chars[charIndex++] = HEX[bytes[i] & 0x0f]; return String.valueOf(chars); |