List of utility methods to do Hex to String
String | convertHexStr(String inStr) convert Hex Str StringBuffer sb = new StringBuffer(); char[] myBuffer = inStr.toCharArray(); for (int i = 0; i < inStr.length(); i++) { short s = (short) myBuffer[i]; String hexS = Integer.toHexString(s).toUpperCase(); if (hexS.length() == 8) { sb.append("&#x" + hexS.substring(4) + ";"); } else { ... |
byte[] | convertHexString(String ss) convert Hex String byte digest[] = new byte[ss.length() / 2]; for (int i = 0; i < digest.length; i++) { String byteString = ss.substring(2 * i, 2 * i + 2); int byteValue = Integer.parseInt(byteString, 16); digest[i] = (byte) byteValue; return digest; |
String | convertHexStringToString(String hexString) Convert the hex string to string. String uHexString = hexString.toLowerCase(); StringBuffer sBuf = new StringBuffer(); for (int i = 0; i < uHexString.length(); i = i + 2) { char c = (char) Integer.parseInt(uHexString.substring(i, i + 2), 16); sBuf.append(c); return sBuf.toString(); |
String | convertHexToString(String hex) convert Hex To String StringBuilder sb = new StringBuilder(); StringBuilder temp = new StringBuilder(); for (int i = 0; i < hex.length() - 1; i += 2) { String output = hex.substring(i, (i + 2)); int decimal = Integer.parseInt(output, 16); sb.append((char) decimal); temp.append(decimal); return sb.toString(); |
String | formatHex(byte[] buf) format Hex if (buf == null) return NullString; try (StringWriter sw = new StringWriter()) { formatHexToWriter(buf, sw, 0); return sw.toString(); } catch (Exception e) { return NullString; |
String | formatHex(byte[] data) format Hex StringWriter w = new StringWriter(); for (byte b : data) { w.append(padLeft(Integer.toHexString(b), 2, '0')); return w.toString(); |
void | formatHexToWriter(byte[] buf, Writer writer, int actualLength) format Hex To Writer formatHexToWriter(buf, writer, 48, actualLength);
return;
|