Zero-Allocation-Hashing
Zero-Allocation-Hashing copied to clipboard
How to correctly calculate hash for byte[][]?
In standard hash functions in Java we can do something like:
Digest digest = new Blake2bDigest(64);
for (int i = 0; i < bytes[0].length; i++) {
digest.update(bytes[0][i], 0, bytes[0][i].length));
}
byte[] hash = new byte[digest.getDigestSize()];
digest.doFinal(hashResult, 0);
return hash;
I understand that it's not possible to have similar API here since the main goal of this project is to have zero allocations. But what will be the correct way to calculate result hash for an array of arrays? Is there any solution except creating one big byte array and put everything into it? Thanks.