Closed mjradwin closed 10 years ago
So, there are two issues at hand here:
offset_basis
is actually a hash; the default seed is actually an FNV-0 hash of the string chongo <Landon Curt Noll> /\../\
. So I can make my API clearer to this effect: that the input into seed()
will be hashed using FNV-0. If it were not, some other strategy e.g. modulus would need to be used to ensure that the seed is within the keyspace of the target hash function.I hadn't noticed this before, but it makes sense now: the reference offset_basis
values are actually computed using FNV-1, and not FNV-1a, and so my offsets will not match the reference offsets. IMO this is basically historical error, but I should nevertheless conform to the extant literature. I will correct this in v1.2.7.
@mjradwin I think I've resolved your issue. See: https://github.com/tjwebb/fnv-plus/blob/master/spec/fnv-plus.js#L110-L127
Awesome, thanks! I will pull the latest and confirm your fix.
Great, let me know.
Pulled 1.2.7 from npm and everything's working great!
Excellent. Thanks for your feedback
How would you propose using your
fnvplus.seed()
API to support using the standard offset_basis values as described in draft-eastlake-fnv-06.txt?We would like to be able to initialize fnvplus so it is compatible with Appendix C: A Few Test Vectors :
In our Java application, we generate unique IDs using 64-bit FNV-1a. For the same given string we would like to be able to generate the identical hash values in JavaScript using fnv-plus. The
fnvplus.seed()
implementation does allow the caller to specify a seed value, but that value is transformed (through hashing) so it can't be used as an offset_basis.