@Test public void byte2HexStr() { String str1 = "abcdefg"; String str2 = DataUtil.byte2HexStr(str1.getBytes()); Assert.equals(str2, "61626364656667", ErrorCodeDef.SYSTEM_ERROR_10001); }
public static String byte2HexStr(final byte[] bs) { char[] chars = HEX_DIGIT.toCharArray(); StringBuilder sb = new StringBuilder(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & NUM_0X0F0) >> NUM_4; sb.append(chars[bit]); bit = bs[i] & NUM_0X0F; sb.append(chars[bit]); } return sb.toString(); }
DataUtil { public static String byte2HexStr(final byte[] bs) { char[] chars = HEX_DIGIT.toCharArray(); StringBuilder sb = new StringBuilder(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & NUM_0X0F0) >> NUM_4; sb.append(chars[bit]); bit = bs[i] & NUM_0X0F; sb.append(chars[bit]); } return sb.toString(); } }
DataUtil { public static String byte2HexStr(final byte[] bs) { char[] chars = HEX_DIGIT.toCharArray(); StringBuilder sb = new StringBuilder(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & NUM_0X0F0) >> NUM_4; sb.append(chars[bit]); bit = bs[i] & NUM_0X0F; sb.append(chars[bit]); } return sb.toString(); }  }
DataUtil { public static String byte2HexStr(final byte[] bs) { char[] chars = HEX_DIGIT.toCharArray(); StringBuilder sb = new StringBuilder(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & NUM_0X0F0) >> NUM_4; sb.append(chars[bit]); bit = bs[i] & NUM_0X0F; sb.append(chars[bit]); } return sb.toString(); }  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 String byte2HexStr(final byte[] bs) { char[] chars = HEX_DIGIT.toCharArray(); StringBuilder sb = new StringBuilder(); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & NUM_0X0F0) >> NUM_4; sb.append(chars[bit]); bit = bs[i] & NUM_0X0F; sb.append(chars[bit]); } return sb.toString(); }  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);  }