UpgradeAction implements Comparable<UpgradeAction> { protected static String getMd5(final String content, final String encoding) { try { final MessageDigest md = MessageDigest.getInstance("MD5"); final byte[] md5 = md.digest(content.getBytes(encoding)); final StringWriter md5Base64 = new StringWriter(); Base64.encode(md5, 0, md5.length, md5Base64); return md5Base64.toString(); } catch (NoSuchAlgorithmException | IOException e) { throw new IllegalStateException("Error while encoding script content.", e); } } UpgradeAction(final String name, final Phase phase, final String contentHash); boolean isRelevant(final InstallContext ctx, final UpgradeInfo info); String getName(); Phase getPhase(); String getContentHash(); abstract void execute(InstallContext ctx); @Override int compareTo(final UpgradeAction o); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testGetMd5() throws Exception { Assert.assertEquals("CY9rzUYh03PK3k6DJie09g==", TestAction.getMd5("test", Charset.defaultCharset().name())); }