GithubHelp home page GithubHelp logo

karanlyons / murmurhash3.js Goto Github PK

View Code? Open in Web Editor NEW
191.0 191.0 55.0 790 KB

MurmurHash3, in JavaScript.

License: MIT License

TypeScript 100.00%
hash incremental-hash javascript murmurhash murmurhash3 progressive-hash typescript

murmurhash3.js's People

Contributors

hansoksendahl avatar karanlyons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

murmurhash3.js's Issues

Output matches C++ reference implementation only for regular ASCII inputs

๐Ÿ‘‹ Hi there!

First of all, thank you for your work! I've been successfully using this library in production for a couple of years and it's been very useful.

Recently we've started using MurmurHash3 on other platforms - we need the results to match and noticed discrepancies between the output of the JS version and the other platforms when the input had characters that were not regular ASCII (i.e. charCodeAt is not between 0 and 127).

This is because in some places the code does key.charCodeAt(i) & 0xff and in other places just key.charCodeAt(i). The byte representation for regular ASCII characters is identical with the character code so for e.g. alphanumeric input this doesn't matter. If the input characters are outside this range, the results start to diverge with the reference implementation.

All the three variants have this problem. For example, here's the output for the x86 32bit version:

Input C++ result (reference) murmurhash3js result
'My hovercraft is full of eels.' 2953494853 2953494853
'My ๐Ÿš€ is full of ๐ŸฆŽ.' 1818098979 2899624186
'ๅ‰ ๆ˜Ÿ ้ซ˜ ็…ง' 3435142074 4163339522

The string was utf-8 encoded before being passed in to the C++ reference as that expects bytes. I think it's fair to expect people using other implementations that ask for bytes will do this.

I decided to change the signature of the function to make it expect bytes. I checked my implementation along with a few others against the reference C++ implementation. You can read more about it and try out an interactive version of the comparison here.

Since I needed a quick release and the new signature is a major/breaking change compared to this implementation, I published my own version of the library as murmurhash3js-revisited. I tried to keep all attribution, but if you have any concerns please let me know!

This issue was copied from pid#3 - I was using that version of murmurhash but since it was forked from this one, looking at the code this seems to have the same problem.

Cheers!

npm module

hi,

thanks for the implementation of murmurHash3 ๐Ÿ‘

I restructured (https://github.com/pid/murmurHash3js) your sources to get ready to publish the module to the npm registry...
I would also look after to add it to the bower registry and publish it to CDN hosting service (ie. http://cdnjs.com/)...

the question here, do you want to manage it by yourself or should I do this tasks?

Note: I want this in a project and for comfort it should be in the npm registry :-)

hash128 not matching python

Hi @karanlyons
I am not getting the hash128 of the this library to match the python mmh3.

Python mmh3:
hex(mmh3.hash128("I will not buy this tobacconist's, it is scratched.")))

Yields: 0x67d73523f0079673d30654abbd8227e3

But in your readme:
murmurHash3.x64.hash128("I will not buy this tobacconist's, it is scratched.");

Yields: d30654abbd8227e367d73523f0079673

Why is there a mismatch?

Please publish a new version of this module

I have submitted a PR to the fork @pid was maintaining to mark it as deprecated.
pid#5

Can you please publish a new version (possibly v3.2.0) of the module
I believe we would just have to merge the above PR and update the repo description once a new version has been published.
Thanks!

3 questions: npm, cdn, utf

  1. Is there an es5 pre-built .js file that I can use? (vis jsdeliver CDN that just 'copies' github/npm').
    I don't want to have to build es5, I just want to use it.

  2. what is eta of npm? (it could be just name + 'karan' prefix)

  3. ASCII only? other implementations are explicit that they are ascii only. Is this utf-8?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.