Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provided basic test vectors #6

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 5 comments
Closed

Please provided basic test vectors #6

GoogleCodeExporter opened this issue Mar 16, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

Would it be possible to have some basic test vectors for testing alternate 
implementations ?

Even a simple single one, like the hash of "The quick brown fox jumps over the 
lazy dog" for all the algorithm flavor would be enough.

I found a lot of wrong implementations of Murmur3 and a such simple test vector 
from the official site will help a lot the developers.


Original issue reported on code.google.com by amadva...@gmail.com on 30 Apr 2011 at 2:06

@GoogleCodeExporter
Copy link
Author

With my implementation, when i hash "The quick brown fox jumps over the lazy 
dog" (using seed 0x9747b28c), i get:

0x2FA826CD

You post what *you* get, and if they match then we'll say it's ready to ship.

Original comment by josejime...@gmail.com on 28 Apr 2012 at 12:20

@GoogleCodeExporter
Copy link
Author

SMHasher uses the VerificationTest function to check if a hash function is 
correctly implemented - it doesn't rely on correct capitalization or 
punctuation of "The quick brown fox..." and catches more implementation errors 
than a single test vector can. I'll make a note on the front page to point it 
out.

Original comment by tanj...@gmail.com on 11 May 2012 at 5:44

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

While SMHasher certainly provides a more complete test suite, it's not very 
helpful in testing the implementation in another language. I have recently 
ported the hash to c# and generated a few test vectors for 3 different seeds 
(0x9747b28c, 0x0, 0xc58f1a7b) including a small collision test against english 
words.

x86_32:  http://pastebin.com/kkggV9Vx
x64_128: http://pastebin.com/k2VDbWkF

Original comment by Darcara...@googlemail.com on 26 May 2012 at 8:43

@GoogleCodeExporter
Copy link
Author

So what is the correct x64_128 hash for "The quick brown fox jumps over the 
lazy dog" and zero seed?
Previous post = 6C1B07BC7BBC4BE347939AC4A93C437A

Python smhasher:
>>> hex(smhasher.murmur3_x64_128(u"The quick brown fox jumps over the lazy 
dog",0))
'0x6c1b07bc7bbc4be347939ac4a93c437aL'

Java Guava:
>>> System.out.println(Hashing.murmur3_128(0).hashString("The quick brown fox 
jumps over the lazy dog"));
4cae51b5316602c01c7c5642843e5fe7

Which version is correct?

Original comment by kamil....@gmail.com on 13 Sep 2012 at 11:20

@GoogleCodeExporter
Copy link
Author

As I mentioned on the Guava bug 
(http://code.google.com/p/guava-libraries/issues/detail?id=1147),

In Guava, if you just call Hasher#hashString(String), it'll hash each character 
in order (no char encoding).

What you want is Hasher#hashString(String, Charset):

HashCode foxHash =  Hashing.murmur3_128(0).hashString(
    "The quick brown fox jumps over the lazy dog", Charsets.UTF_8);
assertEquals("6c1b07bc7bbc4be347939ac4a93c437a", foxHash.toString());
// This is the same as your Python output.

Original comment by kurt.kluever on 13 Sep 2012 at 4:51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant