Digest implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Digest other = (Digest) obj; if (algorithm != other.algorithm) { return false; } if (!Arrays.equals(value, other.value)) { return false; } return true; } Digest();  Digest(DigestAlgorithm algorithm, byte[] value); String getHexValue(); DigestAlgorithm getAlgorithm(); void setAlgorithm(DigestAlgorithm algorithm); byte[] getValue(); void setValue(byte[] value); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEquals() throws Exception { MessageDigest md = MessageDigest.getInstance("SHA-256"); byte[] value = md.digest("Hello World !".getBytes()); Digest d1 = new Digest(DigestAlgorithm.SHA256, value); Digest d2 = new Digest(DigestAlgorithm.SHA256, value); assertEquals(d1, d2); assertEquals(d1.hashCode(), d2.hashCode()); assertArrayEquals(value, d1.getValue()); assertArrayEquals(value, d2.getValue()); assertEquals("07F2BDEF34ED16E3A1BA0DBB7E47B8FD981CE0CCB3E1BFE564D82C423CBA7E47", d1.getHexValue()); assertEquals("07F2BDEF34ED16E3A1BA0DBB7E47B8FD981CE0CCB3E1BFE564D82C423CBA7E47", d2.getHexValue()); }