List of utility methods to do Hex Calculate
String | toHexHashString(byte[] id) to Hex Hash String StringBuilder sb = new StringBuilder(20); assert (id.length == 20); for (int i = 0; i < 20; i++) { int val = id[i] & 0xff; sb.append(HEX_CHARS[val >> 4]); sb.append(HEX_CHARS[val & 0xf]); return sb.toString(); ... |
String | toHexLiteral(int v) to Hex Literal return "0x" + Integer.toHexString(v); |
String | toHexN(long src, int hexn) to Hex N return toHexN(src, hexn, 13);
|
int | ToHexNumber(int c) To Hex Number if (c >= 'A' && c <= 'Z') return 10 + c - 'A'; else if (c >= 'a' && c <= 'z') return 10 + c - 'a'; else if (c >= '0' && c <= '9') return c - '0'; return -1; |
String | toHexOrNegative(int i) to Hex Or Negative return toHex(i, "-1"); |
String | toHexPadZero(byte[] bytes) Convert bytes to hexadecimal representation. StringBuilder ret = new StringBuilder(bytes.length * 2); for (byte b : bytes) { ret.append(hexChars[(b >> 4) & 0xF]); ret.append(hexChars[b & 0xF]); return ret.toString(); |
String | toHexShortString(byte[] bytes) Returns a String representing the byte[] as a sequence of uppercase hexadecimal characters, starting with "0x". StringBuffer sb = new StringBuffer("0x"); boolean leadingZeros = true; if (bytes != null) { for (byte b : bytes) { if (leadingZeros && b == 0) continue; leadingZeros = false; sb.append(HEX_CHARS[0x0F & (b >> 4)]).append(HEX_CHARS[b & 0x0F]); ... |
String | toHexStr(byte b[]) to Hex Str StringBuffer hexString = new StringBuffer(); for (int i = 0; i < b.length; i++) { String plainText = Integer.toHexString(0xff & b[i]); if (plainText.length() < 2) plainText = "0" + plainText; hexString.append(plainText); return hexString.toString(); ... |
String | toHexStr(byte[] b) to Hex Str StringBuffer buffer = new StringBuffer(); for (int i = 0; i < b.length; ++i) { buffer.append(toHexStr(b[i])); return buffer.toString(); |
String | toHexStr(byte[] binary) to Hex Str if (binary == null) { return null; if (binary.length == 0) { return ""; int len = binary.length; StringBuilder sb = new StringBuilder(len * 2); ... |