Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

SpookyHashV2 hashes do not match official implementation #30

Closed
mulgarz opened this issue Oct 27, 2017 · 3 comments
Closed

SpookyHashV2 hashes do not match official implementation #30

mulgarz opened this issue Oct 27, 2017 · 3 comments
Milestone

Comments

@mulgarz
Copy link

mulgarz commented Oct 27, 2017

The 32 bit spookyhashv2 of the string "hello world" should be UInt32 "2617184861" according to the official implementation But with this library it is not.

I have tested all possible ways of feeding this string including different encodings and none of them match.

Testing the same thing with other libraries and this website match properly
https://asecuritysite.com/encryption/Spooky

@brandondahler
Copy link
Owner

Going through the history, it appears that the initial implementation was never correct and therefore all versions of Data.HashFunction.SpookyHash have been producing incorrect values, checked against incorrect test vectors. Because of this, I am going to unlist all existing versions of this package from NuGet.

I will fix and re-release a fixed implementation as soon as I am able to.

@brandondahler
Copy link
Owner

brandondahler commented Nov 25, 2017

Looking at the implementation, it appears that the root cause of the error is because it was incorrectly assumed that the Short(...) function call for byte lengths of 192 and less were just optimizations of the core hash implementation.

This assumption is incorrect -- SpookyHash has a slightly different hash generation implementation for input values of < 192 bytes in length.

The net effect is that we have been producing incorrect results for all values < 192 bytes in length.

@brandondahler
Copy link
Owner

I have verified that this has been resolved in v2.0.

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

No branches or pull requests

2 participants