Hasher { public String toHashedHexString(String string0) throws NoSuchAlgorithmException { return this.toHashedHexString(StringUtil.getAsciiBytes(string0)); } Hasher();  Hasher(Algorithm algorithm); String toHashedHexString(String string0); String toHashedHexString(byte[] bytes); String toHashedBase64String(String string0); String toHashedBase64String(byte[] bytes); byte[] toHashedBytes(byte[] bytes);  }
@Test public void toHashedHexStringMD5() throws Exception { Hasher hasher = new Hasher(); String sample1 = hasher.toHashedHexString(MD5_SAMPLE1); Assert.assertEquals(MD5_SAMPLE1_HASH, sample1); String sample2 = hasher.toHashedHexString(MD5_SAMPLE2); Assert.assertEquals(MD5_SAMPLE2_HASH, sample2); String sample3 = hasher.toHashedHexString(MD5_SAMPLE3); Assert.assertEquals(MD5_SAMPLE3_HASH, sample3); Assert.assertEquals(32, sample3.length()); }
@Test public void toHashedHexStringSHA1() throws Exception { Hasher hasher = new Hasher(Hasher.Algorithm.SHA1); String sample1 = hasher.toHashedHexString(SHA1_SAMPLE1); Assert.assertEquals(SHA1_SAMPLE1_HASH, sample1); String sample2 = hasher.toHashedHexString(SHA1_SAMPLE2); Assert.assertEquals(SHA1_SAMPLE2_HASH, sample2); String sample3 = hasher.toHashedHexString(SHA1_SAMPLE3); Assert.assertEquals(SHA1_SAMPLE3_HASH, sample3); Assert.assertEquals(40, sample3.length()); }
@Test public void toHashedHexStringSHA256() throws Exception { Hasher hasher = new Hasher(Hasher.Algorithm.SHA256); String sample1 = hasher.toHashedHexString(SHA256_SAMPLE1); Assert.assertEquals(SHA256_SAMPLE1_HASH, sample1); String sample2 = hasher.toHashedHexString(SHA256_SAMPLE2); Assert.assertEquals(SHA256_SAMPLE2_HASH, sample2); String sample3 = hasher.toHashedHexString(SHA256_SAMPLE3); Assert.assertEquals(SHA256_SAMPLE3_HASH, sample3); Assert.assertEquals(64, sample3.length()); }
@Test public void toHashedHexStringSHA512() throws Exception { Hasher hasher = new Hasher(Hasher.Algorithm.SHA512); String sample1 = hasher.toHashedHexString(SHA512_SAMPLE1); Assert.assertEquals(SHA512_SAMPLE1_HASH, sample1); String sample2 = hasher.toHashedHexString(SHA512_SAMPLE2); Assert.assertEquals(SHA512_SAMPLE2_HASH, sample2); String sample3 = hasher.toHashedHexString(SHA512_SAMPLE3); Assert.assertEquals(SHA512_SAMPLE3_HASH, sample3); Assert.assertEquals(128, sample3.length()); }