@Test public void testMd5() { assertEquals("24878de96952d64e8149af10f1e96066", Md5Utils.md5("yuzhouwan.com")); }
public static String md5(String s) { if (s == null) { LOGGER.warn("Need not-null input in md5 method!"); return null; } try { MessageDigest digest = MessageDigest.getInstance(MD5); byte[] bytes = s.getBytes(StandardCharsets.UTF_8); digest.update(bytes, 0, bytes.length); return new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { LOGGER.error(String.format("Cannot process md5 method, will return the origin string: %s!", s), e); return s; } }
Md5Utils { public static String md5(String s) { if (s == null) { LOGGER.warn("Need not-null input in md5 method!"); return null; } try { MessageDigest digest = MessageDigest.getInstance(MD5); byte[] bytes = s.getBytes(StandardCharsets.UTF_8); digest.update(bytes, 0, bytes.length); return new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { LOGGER.error(String.format("Cannot process md5 method, will return the origin string: %s!", s), e); return s; } } }
Md5Utils { public static String md5(String s) { if (s == null) { LOGGER.warn("Need not-null input in md5 method!"); return null; } try { MessageDigest digest = MessageDigest.getInstance(MD5); byte[] bytes = s.getBytes(StandardCharsets.UTF_8); digest.update(bytes, 0, bytes.length); return new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { LOGGER.error(String.format("Cannot process md5 method, will return the origin string: %s!", s), e); return s; } } private  Md5Utils(); }
Md5Utils { public static String md5(String s) { if (s == null) { LOGGER.warn("Need not-null input in md5 method!"); return null; } try { MessageDigest digest = MessageDigest.getInstance(MD5); byte[] bytes = s.getBytes(StandardCharsets.UTF_8); digest.update(bytes, 0, bytes.length); return new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { LOGGER.error(String.format("Cannot process md5 method, will return the origin string: %s!", s), e); return s; } } private  Md5Utils(); static String md5(String s); }
Md5Utils { public static String md5(String s) { if (s == null) { LOGGER.warn("Need not-null input in md5 method!"); return null; } try { MessageDigest digest = MessageDigest.getInstance(MD5); byte[] bytes = s.getBytes(StandardCharsets.UTF_8); digest.update(bytes, 0, bytes.length); return new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { LOGGER.error(String.format("Cannot process md5 method, will return the origin string: %s!", s), e); return s; } } private  Md5Utils(); static String md5(String s);  }