List of utility methods to do Hex String Create
String | getHexString(int i) get Hex String return getHexString(new int[] { i }); |
boolean | isHex(String sampleData) Return true if the argument string seems to be a Hex data string, like "a0 13 2f ". for (int i = 0; i < sampleData.length(); i++) { if (!isHexStringChar(sampleData.charAt(i))) return false; return true; |
boolean | isHexStringChar(char c) is Hex String Char return (Character.isDigit(c) || Character.isWhitespace(c) || (("0123456789abcdefABCDEF" .indexOf(c)) >= 0)); |
String | FileNamePathExtension(String filename) File Name Path Extension int index = filename.lastIndexOf("."); if (index != -1) { return filename.substring(index, filename.length()); } else { return ""; |
String | pathExtension(String fileName) path Extension int point = fileName.lastIndexOf('.'); int length = fileName.length(); if (point == -1 || point == length - 1) { return ""; } else { return fileName.substring(point + 1, length); |
byte[] | hexStringToBytes(String hexString) Convert hex string to byte[] if (hexString == null || hexString.equals("")) { return null; hexString = hexString.toUpperCase(); int byteArrayLength = hexString.length() / 2; char[] hexChars = hexString.toCharArray(); byte[] d = new byte[byteArrayLength]; for (int i = 0; i < byteArrayLength; i++) { ... |
void | appendHex(StringBuffer stringbuffer, byte byte0) append Hex stringbuffer.append(toHexChar(byte0 >> 4)); stringbuffer.append(toHexChar(byte0)); |
String | toHexString(char achar0) to Hex String return toHexString((byte) achar0); |
byte[] | decodeHexStr(final String str) decode Hex Str if (str == null) { return null; char[] charArray = str.toCharArray(); if (charArray.length % 2 != 0) { throw new RuntimeException( "hex str length must can mod 2, str:" + str); byte[] bytes = new byte[charArray.length / 2]; for (int i = 0; i < charArray.length; i++) { char c = charArray[i]; int b; if (c >= '0' && c <= '9') { b = (c - '0') << 4; } else if (c >= 'A' && c <= 'F') { b = (c - 'A' + 10) << 4; } else { throw new RuntimeException("unsport hex str:" + str); c = charArray[++i]; if (c >= '0' && c <= '9') { b |= c - '0'; } else if (c >= 'A' && c <= 'F') { b |= c - 'A' + 10; } else { throw new RuntimeException("unsport hex str:" + str); bytes[i / 2] = (byte) b; return bytes; |
String | hexDigest(String input) First encrypts with SHA1 and then spits the result out as a hex string return convertToHex(dataDigest(input));
|