Skip to content

How to correctly calculate hash for byte[][]?  #83

@ruslangm

Description

@ruslangm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions