eu.mais_h.mathsync.digest.Digester Maven / Gradle / Ivy
package eu.mais_h.mathsync.digest;
/**
* Creates digests of items serialized as byte arrays.
*/
public interface Digester {
/**
* Digests an item serialized as an array of bytes.
*
* Any byte array value must be accepted and have a non null
return value: for any a
,
* digest(a) != null
.
*
* All valid inputs should produce in output an array of the same size:for any a1
and
* a2
, digest(a1).length == digest(a2).length
.
*
* The output must be consistent, an identical output should be returned if called twice on the same array: for
* any a1
and a2
, Arrays.equals(a1, a2)
implies
* Arrays.equals(digest(a1), digest(a2))
.
*
* In addition to those constrains, it is recommended that it has the properties of a
* cryptographic hash function.
*
* @param source the item serialized as an array of bytes.
* @return the message digest of the item.
* @throws IllegalArgumentException if the input array is null
.
*/
byte[] digest(byte[] source);
}