@Test public void hexStr2Byte() { String str1 = "61626364656667"; String str2 = new String(DataUtil.hexStr2Byte(str1)); Assert.equals(str2, "abcdefg", ErrorCodeDef.SYSTEM_ERROR_10001); }
public static byte[] hexStr2Byte(final String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i < len; i++) { int pos = i * 2; result[i] = (byte) (toByte(achar[pos]) << NUM_4 | toByte(achar[pos + 1])); } return result; }
DataUtil { public static byte[] hexStr2Byte(final String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i < len; i++) { int pos = i * 2; result[i] = (byte) (toByte(achar[pos]) << NUM_4 | toByte(achar[pos + 1])); } return result; } }
DataUtil { public static byte[] hexStr2Byte(final String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i < len; i++) { int pos = i * 2; result[i] = (byte) (toByte(achar[pos]) << NUM_4 | toByte(achar[pos + 1])); } return result; }  }
DataUtil { public static byte[] hexStr2Byte(final String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i < len; i++) { int pos = i * 2; result[i] = (byte) (toByte(achar[pos]) << NUM_4 | toByte(achar[pos + 1])); } return result; }  static String md5For16(final String msg); static String md5(final String msg); static byte[] base64Decode(final String content); static String base64Encode(final byte[] content); static String encryptPassowrd(final String rawPassword); static boolean matchPassword(final CharSequence rawPassword, final String password); static String encrypt(final String password); static String decrypt(final String password); static String byte2HexStr(final byte[] bs); static byte[] hexStr2Byte(final String hex); }
DataUtil { public static byte[] hexStr2Byte(final String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i < len; i++) { int pos = i * 2; result[i] = (byte) (toByte(achar[pos]) << NUM_4 | toByte(achar[pos + 1])); } return result; }  static String md5For16(final String msg); static String md5(final String msg); static byte[] base64Decode(final String content); static String base64Encode(final byte[] content); static String encryptPassowrd(final String rawPassword); static boolean matchPassword(final CharSequence rawPassword, final String password); static String encrypt(final String password); static String decrypt(final String password); static String byte2HexStr(final byte[] bs); static byte[] hexStr2Byte(final String hex);  }