@Test public void testGenerateHash() { String test = "testing"; String expectedHash = "ae2b1fca515949e5d54fb22b8ed95575"; String hash = HashUtil.generateHash(test); assertThat(hash).isEqualTo(expectedHash); }
public static String generateHash(String hashContent) throws RuntimeException { try { MessageDigest exc = MessageDigest.getInstance("MD5"); exc.reset(); return new String( Hex.encodeHex( exc.digest( hashContent.getBytes(CharEncoding.UTF_8)))); } catch (Exception e) { throw new RuntimeException(e); } }
HashUtil { public static String generateHash(String hashContent) throws RuntimeException { try { MessageDigest exc = MessageDigest.getInstance("MD5"); exc.reset(); return new String( Hex.encodeHex( exc.digest( hashContent.getBytes(CharEncoding.UTF_8)))); } catch (Exception e) { throw new RuntimeException(e); } } }
HashUtil { public static String generateHash(String hashContent) throws RuntimeException { try { MessageDigest exc = MessageDigest.getInstance("MD5"); exc.reset(); return new String( Hex.encodeHex( exc.digest( hashContent.getBytes(CharEncoding.UTF_8)))); } catch (Exception e) { throw new RuntimeException(e); } } @SuppressWarnings("unused") private  HashUtil(); }
HashUtil { public static String generateHash(String hashContent) throws RuntimeException { try { MessageDigest exc = MessageDigest.getInstance("MD5"); exc.reset(); return new String( Hex.encodeHex( exc.digest( hashContent.getBytes(CharEncoding.UTF_8)))); } catch (Exception e) { throw new RuntimeException(e); } } @SuppressWarnings("unused") private  HashUtil(); static String generateHash(String hashContent); }
HashUtil { public static String generateHash(String hashContent) throws RuntimeException { try { MessageDigest exc = MessageDigest.getInstance("MD5"); exc.reset(); return new String( Hex.encodeHex( exc.digest( hashContent.getBytes(CharEncoding.UTF_8)))); } catch (Exception e) { throw new RuntimeException(e); } } @SuppressWarnings("unused") private  HashUtil(); static String generateHash(String hashContent);  }