DataUtil { public static String md5(final String msg) { byte[] msgBytes = msg.getBytes(); try { MessageDigest mdInst = MessageDigest.getInstance("MD5"); mdInst.update(msgBytes); byte[] md = mdInst.digest(); int j = md.length; char str[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = md[i]; str[k++] = hexDigits[byte0 >>> NUM_4 & NUM_0XF]; str[k++] = hexDigits[byte0 & NUM_0XF]; } return new String(str); } catch (NoSuchAlgorithmException e) { throw new UtilException(ErrorCodeDef.MD5_ERROR_10036, e); } }  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);  }
@Test public void md5() { String str1 = "123456"; String str2 = DataUtil.md5(str1); Assert.equals(str2, "E10ADC3949BA59ABBE56E057F20F883E", ErrorCodeDef.SYSTEM_ERROR_10001); }