List of utility methods to do Byte Array to Hex
String | bytesToHex(byte[] bytes, int size, char delim) Convert bytes to hex string char[] hexChars; if (bytes == null) return ""; if (delim == 0) { hexChars = new char[size * 2]; for (int j = 0; j < size; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; ... |
String | bytesToHex(byte[] data) Convert byte array to readable byte string. char[] hexChars = new char[data.length * 2]; for (int j = 0; j < data.length; j++) { int v = data[j] & 0xFF; hexChars[j * 2] = "0123456789ABCDEF".toCharArray()[v >>> 4]; hexChars[j * 2 + 1] = "0123456789ABCDEF".toCharArray()[v & 0x0F]; return new String(hexChars); |
String | bytesToHex(byte[] data) This utility method is passed an array of bytes. StringBuffer retval = new StringBuffer(); for (int i = 0; i < data.length; i++) { retval.append(HEX[(data[i] >> 4) & 0x0F]); retval.append(HEX[data[i] & 0x0F]); return retval.toString(); |
String | bytesToHex(byte[] data) bytes To Hex StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { buf.append(byteToHex(data[i]).toUpperCase()); return (buf.toString()); |
String | bytesToHex(byte[] data) bytes To Hex return bytesToHex(data, 0, data.length);
|
String | bytesToHex(byte[] data) bytes To Hex StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { int halfbyte = (data[i] >>> 4) & 0x0F; int two_halfs = 0; do { if ((0 <= halfbyte) && (halfbyte <= 9)) buf.append((char) ('0' + halfbyte)); else ... |
String | bytesToHex(byte[] data, char[] chars) bytes To Hex int length = data.length; char[] out = new char[length << 1]; for (int i = 0, j = 0; i < length; i++) { out[j++] = chars[(0xF0 & data[i]) >>> 4]; out[j++] = chars[0x0F & data[i]]; return new String(out); |
String | bytesToHex(byte[] data, int m, int n) bytes To Hex char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; char[] temp = new char[n * 2]; int k = m + n; for (int l = m; l < k; l++) { byte b = data[l]; temp[l * 2] = hexDigits[b >>> 4 & 0x0f]; temp[l * 2 + 1] = hexDigits[b & 0x0f]; return new String(temp); |
String | bytesToHex(byte[] digest) bytes To Hex StringBuffer buffer = new StringBuffer(""); for (int i = 0; i < digest.length; i++) { String hexValue = Integer.toHexString(digest[i] & 0xFF); if (hexValue.length() == 1) { buffer.append(0); buffer.append(hexValue); return buffer.toString(); |
String | bytesToHex(byte[] in) bytes To Hex StringBuffer hex = new StringBuffer(); for (int i = 0; i < in.length; i++) { int msb = (in[i] & 0xFF) / 16; int lsb = (in[i] & 0xFF) % 16; hex.append(hexChars[msb]); hex.append(hexChars[lsb]); return hex.toString(); ... |