-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
When input is empty array/span all hashes throws an exception.
var bytes = new byte[0];
var hash = xxHash3.ComputeHash(bytes, bytes.Length); //exception
var span = bytes.AsSpan();
var hash2 = xxHash3.ComputeHash(span, span.Length); //exception
In all hash functions must be guard clause like this
if (data.Length == 0)
return ComputeEmptyHash(seed);
...
private static unsafe uint ComputeEmptyHash(uint seed)
{
var pData = stackalloc byte[1]; //doesn't work with zero
return UnsafeComputeHash(pData, 0, seed);
}
Metadata
Metadata
Assignees
Labels
No labels