@Test public void testMd5Hex() throws NoSuchAlgorithmException { Assert.assertEquals("d41d8cd98f00b204e9800998ecf8427e", MD5Utils.md5Hex("", Constants.ENCODE)); Assert.assertEquals("acbd18db4cc2f85cedef654fccc4a4d8", MD5Utils.md5Hex("foo", Constants.ENCODE)); Assert.assertEquals("02f463eb799797e2a978fb1a2ae2991e", MD5Utils.md5Hex( "38c5ee9532f037a20b93d0f804cf111fca4003e451d09a692d9dea8032308d9c64eda9047fcd5e850284a49b1a0cfb2ecd45", Constants.ENCODE)); Assert.assertEquals("d41d8cd98f00b204e9800998ecf8427e", MD5Utils.md5Hex(new byte[0])); Assert.assertEquals("5289df737df57326fcdd22597afb1fac", MD5Utils.md5Hex(new byte[] {1, 2, 3})); }
public static String md5Hex(byte[] bytes) throws NoSuchAlgorithmException { try { MessageDigest messageDigest = MESSAGE_DIGEST_LOCAL.get(); if (messageDigest != null) { return encodeHexString(messageDigest.digest(bytes)); } throw new NoSuchAlgorithmException("MessageDigest get MD5 instance error"); } finally { MESSAGE_DIGEST_LOCAL.remove(); } }
MD5Utils { public static String md5Hex(byte[] bytes) throws NoSuchAlgorithmException { try { MessageDigest messageDigest = MESSAGE_DIGEST_LOCAL.get(); if (messageDigest != null) { return encodeHexString(messageDigest.digest(bytes)); } throw new NoSuchAlgorithmException("MessageDigest get MD5 instance error"); } finally { MESSAGE_DIGEST_LOCAL.remove(); } } }
MD5Utils { public static String md5Hex(byte[] bytes) throws NoSuchAlgorithmException { try { MessageDigest messageDigest = MESSAGE_DIGEST_LOCAL.get(); if (messageDigest != null) { return encodeHexString(messageDigest.digest(bytes)); } throw new NoSuchAlgorithmException("MessageDigest get MD5 instance error"); } finally { MESSAGE_DIGEST_LOCAL.remove(); } }  }
MD5Utils { public static String md5Hex(byte[] bytes) throws NoSuchAlgorithmException { try { MessageDigest messageDigest = MESSAGE_DIGEST_LOCAL.get(); if (messageDigest != null) { return encodeHexString(messageDigest.digest(bytes)); } throw new NoSuchAlgorithmException("MessageDigest get MD5 instance error"); } finally { MESSAGE_DIGEST_LOCAL.remove(); } }  static String md5Hex(byte[] bytes); static String md5Hex(String value, String encode); static String encodeHexString(byte[] bytes); }
MD5Utils { public static String md5Hex(byte[] bytes) throws NoSuchAlgorithmException { try { MessageDigest messageDigest = MESSAGE_DIGEST_LOCAL.get(); if (messageDigest != null) { return encodeHexString(messageDigest.digest(bytes)); } throw new NoSuchAlgorithmException("MessageDigest get MD5 instance error"); } finally { MESSAGE_DIGEST_LOCAL.remove(); } }  static String md5Hex(byte[] bytes); static String md5Hex(String value, String encode); static String encodeHexString(byte[] bytes);  }