Open Source Release: js-murmur3-128

As you can imagine from of all of our blog posts about hashing that we hash a lot of things. While the various hashing algorithms may be well-defined, the devil is always in the details especially when working with multiple languages that have different ways of representing numbers. We’re happy to announce the open-source release of AK’s 128bit Murmur3 implementation for JavaScript, js-murmur3-128. We are releasing this code under the Apache License, Version 2.0 matching our other open source offerings.


The goal of the implementation is to produce a hash value that is equivalent to the C++ and Java (Guava) versions for the same input and it must be usable in the browser. (Full disclosure: we’re still working through some signed/unsigned issues between the C++ and Java/JavaScript versions. The Java and JavaScript versions match exactly.)


Java (Guava):

final int seed = 0;
final byte[] bytes = { (byte)0xDE, (byte)0xAD, (byte)0xBE, (byte)0xEF,
                       (byte)0xFE, (byte)0xED, (byte)0xFA, (byte)0xCE }; hashFunction =; hashCode = hashFunction.newHasher()


var seed = 0;
var rawKey = new ArrayBuffer(8);
    var byteView = new Int8Array(rawKey);
        byteView[0] = 0xDE; byteView[1] = 0xAD; byteView[2] = 0xBE; byteView[3] = 0xEF;
        byteView[4] = 0xFE; byteView[5] = 0xED; byteView[6] = 0xFA; byteView[7] = 0xCE;
console.log(murmur3.hash128(rawKey, seed));


  1. Heads up: Opera 10.5.x and 10.6.x have some weird behaviour when you convert to and from signed and unsigned with the shift operators, it will work the first few times, but then it gives really weird results (it looks like the JIT is optimizing the code wrong). We recently ran into that problem with a Mersenne-Twister implementation that we ported from C to JavaScript. Took us a while to discover.

  2. Thanks for the tip! Are there any known work arounds or what are you guys doing to work around it?

  3. Wonderful, this is exactly what I’ve been longing for!
    Perhaps I’ve missed something trivial, in that case sorry for that, but I get “Uncaught ReferenceError: goog is not defined on line 56 (chrome)

  4. Silly me, should have read the instructions -.-

  5. Hello Joel! I’m glad that this was able to fit a need for you! If you get a chance, let us know how you’re using it (either comment here or email one of us directly) so that we can get a feel for what directions that we should take it in. If you have any suggestions on features, etc please let us know!


  1. […] Fast forward a few years to today. We had finally enough in the meager science/research budget to pick up an intern for a few months and as a side project I tasked him with turning our dream into a reality. Without further ado, we are pleased to announce the open-source release of AK’s HyperLogLog implementation for JavaScript, js-hll. We are releasing this code under the Apache License, Version 2.0 matching our other open source offerings. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: