The result of calling any methods after calling {@link #hash} is undefined.
Warning: Chunks of data that are put into the {@link Hasher} are not delimited.The resulting {@link HashCode} is dependent only on the bytes inserted, and the order in whichthey were inserted, not how those bytes were chunked into discrete put() operations. For example, the following three expressions all generate colliding hash codes:
{@code newHasher().putString("ab").putString("c").hash() newHasher().putString("a").putString("bc").hash() newHasher().putChar('a').putChar('b').putChar('c').hash()}If you wish to avoid this, you should either prepend or append the size of each chunk. For example:
{@code newHasher().putInt(s1.length()).putString(s1).putInt(s2.length()).putString(s2).hash()}@author Kevin Bourrillion @since 11.0
|
|