Ruby implementation of noncriptographic hash Murmur3 (both native and pure ruby)
Java C Ruby
Latest commit 85cb4b1 Oct 20, 2015 @funny-falcon Merge pull request #7 from bogdanovich/master
Add str_hexdigest to README.md
Permalink
Failed to load latest commit information.
ext/murmurhash3 v0.1.6 - native jruby gem Dec 24, 2014
lib v0.1.6 - native jruby gem Dec 24, 2014
test native version Aug 2, 2012
.gitignore pure ruby works Aug 2, 2012
Gemfile pure ruby works Aug 2, 2012
LICENSE pure ruby works Aug 2, 2012
README.md Add str_hexdigest to README.md Oct 20, 2015
Rakefile v0.1.6 - native jruby gem Dec 24, 2014

README.md

Murmurhash3

This is an implementation of MurmurHash3 - noncriptographic hash function.

It includes x86_32bit variant and x64_128bit variant. x86_128bit variant is ommited.

It exposes finalization mix functions as variant of superfast integer hashing.

Installation

Add this line to your application's Gemfile:

gem 'murmurhash3'

And then execute:

$ bundle

Or install it yourself as:

$ gem install murmurhash3

Usage

    require 'murmurhash3'

    MurmurHash3::V32.str_digest(some_string, seed)
    MurmurHash3::V32.str_hexdigest(some_string, seed)
    MurmurHash3::V32.str_base64digest(some_string, seed)
    MurmurHash3::V32.fmix(some_32bit_integer)
    MurmurHash3::V32.str_hash(some_string)
    MurmurHash3::V32.str_hash(some_string, seed)
    MurmurHash3::V32.int32_hash(some_32bit_integer)
    MurmurHash3::V32.int32_hash(some_32bit_integer, seed)
    MurmurHash3::V32.int64_hash(some_64bit_integer)
    MurmurHash3::V32.int64_hash(some_64bit_integer, seed)

    class SomeClass
      include MurmurHash3::V32
      def func
        murmur3_32_str_digest(some_string)
        murmur3_32_str_hexdigest(some_string)
        murmur3_32_str_base64digest(some_string)
        murmur3_32_fmix(some_32bit_integer)
        murmur3_32_str_hash(some_string)
        murmur3_32_str_hash(some_string, seed)
        murmur3_32_int32_hash(some_32bit_integer)
        murmur3_32_int32_hash(some_32bit_integer, seed)
        murmur3_32_int64_hash(some_64bit_integer)
        murmur3_32_int64_hash(some_64bit_integer, seed)
      end
    end

    MurmurHash3::V128.str_digest(some_string, seed)        # => String
    MurmurHash3::V128.str_hexdigest(some_string, seed)     # => String
    MurmurHash3::V128.str_base64digest(some_string, seed)  # => String
    MurmurHash3::V128.fmix(some_64bit_integer)             # => int64
    MurmurHash3::V128.str_hash(some_string)                # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.str_hash(some_string, seed)          # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int32_hash(some_32bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int32_hash(some_32bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int64_hash(some_64bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
    MurmurHash3::V128.int64_hash(some_64bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]

    class SomeClass
      include MurmurHash3::V128
      def func
        murmur3_128_str_digest(some_string)              # => String
        murmur3_128_str_hexdigest(some_string)           # => String
        murmur3_128_str_base64digest(some_string)        # => String
        murmur3_128_fmix(some_64bit_integer)             # => int64
        murmur3_128_str_hash(some_string)                # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_str_hash(some_string, seed)          # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int32_hash(some_32bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int32_hash(some_32bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int64_hash(some_64bit_integer)       # => [int32_0, int32_1, int32_2, int32_3]
        murmur3_128_int64_hash(some_64bit_integer, seed) # => [int32_0, int32_1, int32_2, int32_3]
      end
    end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request