@Test void testMd5Hash() { String plaintext = "password"; String hashed = "5f4dcc3b5aa765d61d8327deb882cf99"; String computed = HashUtilities.performHash("MD5", plaintext); assertTrue(hashed.equalsIgnoreCase(computed)); }
public static String performHash(String hashAlgorithm, String plaintext) { try { MessageDigest md = MessageDigest.getInstance(hashAlgorithm); byte[] digest = md.digest(plaintext.getBytes(StandardCharsets.UTF_8)); return ADAPTER.marshal(digest); } catch (NoSuchAlgorithmException e) { LOG.error("Attempted to hash with algorithm {}, which is not supported by the Java library. " + "Requests are going to fail while this continues.", hashAlgorithm, e); throw new RuntimeException(e); } }
HashUtilities { public static String performHash(String hashAlgorithm, String plaintext) { try { MessageDigest md = MessageDigest.getInstance(hashAlgorithm); byte[] digest = md.digest(plaintext.getBytes(StandardCharsets.UTF_8)); return ADAPTER.marshal(digest); } catch (NoSuchAlgorithmException e) { LOG.error("Attempted to hash with algorithm {}, which is not supported by the Java library. " + "Requests are going to fail while this continues.", hashAlgorithm, e); throw new RuntimeException(e); } } }
HashUtilities { public static String performHash(String hashAlgorithm, String plaintext) { try { MessageDigest md = MessageDigest.getInstance(hashAlgorithm); byte[] digest = md.digest(plaintext.getBytes(StandardCharsets.UTF_8)); return ADAPTER.marshal(digest); } catch (NoSuchAlgorithmException e) { LOG.error("Attempted to hash with algorithm {}, which is not supported by the Java library. " + "Requests are going to fail while this continues.", hashAlgorithm, e); throw new RuntimeException(e); } }  }
HashUtilities { public static String performHash(String hashAlgorithm, String plaintext) { try { MessageDigest md = MessageDigest.getInstance(hashAlgorithm); byte[] digest = md.digest(plaintext.getBytes(StandardCharsets.UTF_8)); return ADAPTER.marshal(digest); } catch (NoSuchAlgorithmException e) { LOG.error("Attempted to hash with algorithm {}, which is not supported by the Java library. " + "Requests are going to fail while this continues.", hashAlgorithm, e); throw new RuntimeException(e); } }  static String performHash(String hashAlgorithm, String plaintext); }
HashUtilities { public static String performHash(String hashAlgorithm, String plaintext) { try { MessageDigest md = MessageDigest.getInstance(hashAlgorithm); byte[] digest = md.digest(plaintext.getBytes(StandardCharsets.UTF_8)); return ADAPTER.marshal(digest); } catch (NoSuchAlgorithmException e) { LOG.error("Attempted to hash with algorithm {}, which is not supported by the Java library. " + "Requests are going to fail while this continues.", hashAlgorithm, e); throw new RuntimeException(e); } }  static String performHash(String hashAlgorithm, String plaintext);  }