3

This implementation of Murmur hash yields different results when called twice in a row:

Murmur3 m3 = new Murmur3();
var la = m3.ComputeHash(new byte[] { 1, 2 });
var lb = m3.ComputeHash(new byte[] { 1, 2 });
//la and lb now have different bytes

Nowhere in Murmur description on wikipedia it is mentioned, that the hash should take into account previous hashed values, or maintain/check sequence of what was hashed.

Is it a bug in this implementation? Did I misundestand Wikipedia article? Did I misunderstand the implementer intention?

5

The ComputeHash method in the code you link just calls ProcessBytes and then returns the hash. ProcessBytes is used for incremental hashing of large quantities of data, so retains memory between calls. In this implementation, you should not call ComputeHash more than once, as the later calls do not start from the correct register values. Create a new object before the second call to get correct results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.