Skip to content

Repository files navigation

Murmur redux

murmur_redux is a small native Ruby wrapper around the public-domain MurmurHash3 implementation. It was originally based on murmurhash3-ruby.

Security warning: MurmurHash is a fast, non-cryptographic hash. Do not use it for passwords, signatures, authentication, integrity checks, or any situation requiring collision or preimage resistance. Use a cryptographic construction from Ruby's OpenSSL or Digest libraries instead.

Status and compatibility

This project is an archived, unsupported compatibility release. It is not under active feature development and no response time is promised for bug or security reports. Users should plan to migrate to an actively maintained implementation.

Version 1.0.4 requires Ruby 3.3 or newer (and is constrained to Ruby 4.x or earlier). It is tested on Ruby 4.0.6, arm64-darwin25 (macOS/Darwin 25.6), using Apple Clang 21.0.0. The extension has not been validated on Windows, big-endian systems, 32-bit systems, or strict-alignment architectures.

The native implementation exposes MurmurHash3 x86 32-bit and x64 128-bit variants. MurmurRedux::Hash.digest uses the x64 128-bit variant. Hash output is retained for compatibility and can be platform-dependent for integer input or on architectures with different byte order; it must not be treated as a portable cryptographic digest.

Installation

A C compiler and Ruby development headers are required.

gem "murmur_redux"

Usage

require "murmur_redux"

MurmurRedux::Hash.digest("test")
# => "9de1bd74cc287dac824dbdf93182129a"

MurmurRedux::V32.str_hash("test")
MurmurRedux::V128.str_hash("test")

The optional second argument to the native hash methods is a 32-bit seed. The existing MurmurRedux::V32, MurmurRedux::V128, and MurmurRedux::Hash.digest APIs remain available.

Development

bundle install
bundle exec rake compile test
bundle exec rake build

License

The embedded MurmurHash3 source by Austin Appleby is in the public domain, as noted in the source file. The Ruby gem is available under the MIT License:

Copyright (c) 2013 Marian Posaceanu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A simple wrapper around murmurhash3 C extension

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages