SHA { public static String sha256(String base) { return sha(base, "SHA-256"); }  static String sha1(String base); static String sha256(String base); static String sha(String base, String alg); static byte[] sha(byte[] base, String alg);  }
@Test public void basic() { String sha256 = SHA.sha256(SOME_STRING); assertNotNull(sha256); assertTrue(!sha256.equals(SOME_STRING)); }
@Test public void uniqeResult() { String sha1 = SHA.sha256(SOME_STRING); String sha2 = SHA.sha256(SOME_OTHER_STRING); assertTrue(!sha1.equals(sha2)); }
@Test public void deterministic() { String sha1 = SHA.sha256(SOME_STRING); assertTrue(sha1.equals(SHA.sha256(SOME_STRING))); }
@Test public void nullInput() { String sha256; try { sha256 = SHA.sha256(null); } catch (Exception e) { assertTrue(e instanceof RuntimeException); } }