Closed gobimcp closed 4 years ago
node-murmurhash-native handles only strings and raw bytes. Enything else should be first written to a Buffer. The result will be different if you use BE or LE byte order. In Java long types are 64-bit integers. There is no equivalent in javascript of such datatype, so I'm not sure what you are actually trying to achieve. Please make a gist with both examples (in nodejs and in java).
@royaltm The problem: We have a switch to turn on new features in Java backend code, which is based on murmurhash thats implemented using guava library, and we have many features turned on using this switch to existing customers for a long time. Now we will need implement the switch logic in the frontend as well so that the feature will get turned on / off both in front end and backend. Since we have existing customers in java backend logic, we cannot change that logic. Thats the reason I am trying to match the murmur hash result of the input numbers in javascript with the value returned in java.
This is the gist of the code that are giving different values (based on numbers) https://gist.github.com/gobimcp/5d365295afce3d54b14d05179c34815d.
The below is the string hash in both java and js and the results are matching. https://gist.github.com/gobimcp/e97f96386684a2f4feb2685043c716a4
I've posted an answer in a comment to your gist: https://gist.github.com/gobimcp/5d365295afce3d54b14d05179c34815d
I'm closing this as it's not an issue of this library.
I am trying to get the same result for murmurhash in java and javascript. In java, I am using guava's implementation https://github.com/google/guava/blob/master/android/guava/src/com/google/common/hash/Murmur3_32HashFunction.java#L109.
If I use hashString in java and new MurmurHash3(String(XX)).result() from this library, the results are matching. But If use java's hashLong, the results are not matching. Any idea how to make this work.