@Test public void encrypt() { String computeValue = "dasfjkl;sdjfkldsafjodsiu29-w0483290-48230-8idfsopafjdls;afkd;safkd;safdsaf"; Assert.assertEquals(MD5Util.encrypt(computeValue), MD5Util.encrypt(computeValue)); String changeValue = "dasfjkl;sdjfkldsafjodsiu29-w0483290-48230-8idfsopafjdls;afkd;safkd;safdsa5"; Assert.assertNotEquals(MD5Util.encrypt(computeValue), MD5Util.encrypt(changeValue)); }
public static String encrypt(String dataStr) { MessageDigest messageDigest = null; String result = ""; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(dataStr.getBytes(StandardCharsets.UTF_8)); result = new BigInteger(1, messageDigest.digest(dataStr.getBytes(StandardCharsets.UTF_8))) .toString(16); } catch (NoSuchAlgorithmException e) { LOGGER.error("Failed to generate MD5 . ", e); } return result; }
MD5Util { public static String encrypt(String dataStr) { MessageDigest messageDigest = null; String result = ""; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(dataStr.getBytes(StandardCharsets.UTF_8)); result = new BigInteger(1, messageDigest.digest(dataStr.getBytes(StandardCharsets.UTF_8))) .toString(16); } catch (NoSuchAlgorithmException e) { LOGGER.error("Failed to generate MD5 . ", e); } return result; } }
MD5Util { public static String encrypt(String dataStr) { MessageDigest messageDigest = null; String result = ""; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(dataStr.getBytes(StandardCharsets.UTF_8)); result = new BigInteger(1, messageDigest.digest(dataStr.getBytes(StandardCharsets.UTF_8))) .toString(16); } catch (NoSuchAlgorithmException e) { LOGGER.error("Failed to generate MD5 . ", e); } return result; }  }
MD5Util { public static String encrypt(String dataStr) { MessageDigest messageDigest = null; String result = ""; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(dataStr.getBytes(StandardCharsets.UTF_8)); result = new BigInteger(1, messageDigest.digest(dataStr.getBytes(StandardCharsets.UTF_8))) .toString(16); } catch (NoSuchAlgorithmException e) { LOGGER.error("Failed to generate MD5 . ", e); } return result; }  static String encrypt(String dataStr); }
MD5Util { public static String encrypt(String dataStr) { MessageDigest messageDigest = null; String result = ""; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(dataStr.getBytes(StandardCharsets.UTF_8)); result = new BigInteger(1, messageDigest.digest(dataStr.getBytes(StandardCharsets.UTF_8))) .toString(16); } catch (NoSuchAlgorithmException e) { LOGGER.error("Failed to generate MD5 . ", e); } return result; }  static String encrypt(String dataStr);  }