#xxHash3 collision

1 messages · Page 1 of 1 (latest)

hollow thunder
#

Hi!

I have a collision problem with xxHash3.Hash64.

I have a method to convert string to hash :

        {
            fixed ( char* s = input )
                Hash = xxHash3.Hash64(s, input.Length);

            Assert.IsFalse(Hash.Equals(default));
        }

The result for test "foo1" & "foo2", see attachment

It seems that the hash is based on the length and not the content of the memory block because all foo[0-9] have the same result :/

From the github implementation, collision can't happen with an input of a lenght < 16

Is it a bug or I miss something ?

narrow fiber
#

You’re working with a char* but the actual method signature uses void* and expects a length in bytes. You’re passing in the string length, which would be 4 and only accounts for the first 2 chars, so really you’re hashing “fo”