List of utility methods to do Hex String Create
String | hexToBt64(String hex) hex To Bt String binary = ""; for (int i = 0; i < 16; i++) { binary += hexToBt4(hex.substring(i, i + 1)); return binary; |
byte[] | hexToBytes(String hex) hex To Bytes hex = removeSpaces(hex); assert hex.length() % 2 == 0 : "must be even number of bytes"; int resultLen = hex.length() / 2; byte[] result = new byte[resultLen]; int j = 0; for (int i = 0; i < resultLen; i++) { result[i] = (byte) (Byte.parseByte(hex.substring(j, ++j), 16) << 4 | Byte .parseByte(hex.substring(j, ++j), 16)); ... |
String | convertToHex(byte[] data) Converts a byte array into a hex string. 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 | convertToHex(byte[] data) convert To Hex StringBuffer sb = new StringBuffer(); String hex = null; hex = Base64 .encodeToString(data, 0, data.length, Base64.NO_PADDING); sb.append(hex); return sb.toString(); |
String | byte2HexStr(byte[] b, int length) byte Hex Str String hs = ""; String stmp = ""; for (int n = 0; n < length; ++n) { stmp = Integer.toHexString(b[n] & 0xFF); if (stmp.length() == 1) { hs = hs + "0" + stmp; } else { hs = hs + stmp; ... |
String | byte2hex(byte[] bytes) bytehex StringBuilder sign = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(bytes[i] & 0xFF); if (hex.length() == 1) { sign.append("0"); sign.append(hex.toUpperCase()); return sign.toString(); |
String | bytesToHex(byte[] bytes) bytes To Hex if (bytes == null) return "0000000000000000000000000000000000000000"; char[] hexChars = new char[bytes.length * 2]; int v; for (int j = 0; j < bytes.length; j++) { v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; ... |
String | encodeHex(byte[] bytes) encode Hex final char[] hex = new char[bytes.length * 2]; int i = 0; for (byte b : bytes) { hex[i++] = HEX_DIGITS[(b >> 4) & 0x0f]; hex[i++] = HEX_DIGITS[b & 0x0f]; return String.valueOf(hex); |
String | encodeHex(byte[] pData) encode Hex int l = pData.length; char[] out = new char[l << 1]; for (int i = 0, j = 0; i < l; i++) { out[j++] = DIGITS[(0xF0 & pData[i]) >>> 4]; out[j++] = DIGITS[0x0F & pData[i]]; return new String(out); |
String | hex(int value, int digits) hex String stuff = Integer.toHexString(value).toUpperCase(); int length = stuff.length(); if (length > digits) { return stuff.substring(length - digits); } else if (length < digits) { return "00000000".substring(8 - (digits - length)) + stuff; return stuff; ... |