List of utility methods to do Hex Calculate
String | toHex(byte[] data, int bytesPerGroup) to Hex StringBuilder sb = new StringBuilder(); for (int i = 0, n = data.length; i < n; i++) { if ((i % bytesPerGroup) == 0 && i > 0) { sb.append(' '); sb.append(HEX[(data[i] >> 4) & 0xf]); sb.append(HEX[data[i] & 0xf]); return sb.toString(); |
String | toHex(byte[] data, int length) Return length many bytes of the passed in byte array as a hex string. StringBuffer buf = new StringBuffer(); for (int i = 0; i != length; i++) { int v = data[i] & 0xff; buf.append(digits.charAt(v >> 4)); buf.append(digits.charAt(v & 0xf)); return buf.toString(); |
String | toHex(byte[] data, int off, int len) to Hex StringBuffer s = new StringBuffer(); for (int i = off; i < off + len; i++) { if (i > off) { s.append(' '); s.append(toHex(0x000000ff & data[i])); return s.toString(); ... |
String | toHex(byte[] data, int perLine, boolean offset) Convert a byte array to a hexidacimal representation as a string. int size = data.length * 3; int lines = size / perLine; if (offset) size += lines * 13; size += lines; StringBuffer sb = new StringBuffer(size); StringBuffer sb1 = new StringBuffer(13); for (int i = 0; i < data.length; i += perLine) { ... |
String | toHex(byte[] dBytes) to Hex char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; StringBuffer back = new StringBuffer(); for (int i = 0; i < dBytes.length; ++i) { int d = dBytes[i]; if (d < 0) { d = 256 + d; int a = d / 16; ... |
String | toHex(byte[] digest) to Hex char[] result = new char[digest.length * 2]; for (int i = 0; i < digest.length; i++) { toChars(digest[i], result, i * 2); return new String(result); |
String | toHex(byte[] digest) to Hex StringBuilder sb = new StringBuilder(digest.length * 2); for (byte b : digest) { String hex = Integer.toHexString(b); if (hex.length() == 1) { sb.append("0"); } else if (hex.length() == 8) { hex = hex.substring(6); sb.append(hex); return sb.toString().toLowerCase(); |
String | toHex(byte[] inBytes) toHex (byte []) returns the passed byte array in hex StringBuffer outString = new StringBuffer(4 * inBytes.length); for (int i = 0; i < inBytes.length; i++) { String hexChar; if (inBytes[i] < 0) hexChar = Integer.toHexString(256 + inBytes[i]); else hexChar = Integer.toHexString(inBytes[i]); if (hexChar.length() % 2 == 1) ... |
String | toHex(byte[] input) to Hex StringBuilder sb = new StringBuilder(); for (byte b : input) { int i = (b >> 4) & 0x0f; if (i > 9) { sb.append((char) (i + 55)); } else { sb.append((char) (i + 48)); i = b & 0x0f; if (i > 9) { sb.append((char) (i + 55)); } else { sb.append((char) (i + 48)); return sb.toString(); |
String | toHex(byte[] key) to Hex return key == null ? "null" : toHex(key, 0, key.length); |