Packages

Hash strings using the non-cryptographic hash Murmur3 in Gleam

Current section

Files

Jump to
mumu src mumu.gleam
Raw

src/mumu.gleam

/// Hash strings into a sequence of numbers using the x86_32bit variant of the murmur3 algorithm.
///
/// ```gleam
/// hash("some data")
/// // -> 875_689_107
/// ```
///
pub fn hash(input: String) -> Int {
hash_with_seed(input, 0)
}
/// Hash strings using different seed values.
///
/// ```gleam
/// hash_with_seed("some data", 1)
/// // -> 875_689_107
/// ```
///
@external(erlang, "erlang_murmurhash", "murmurhash3_32")
@external(javascript, "./murmurhash3_gc.mjs", "murmurhash3_32_gc")
pub fn hash_with_seed(input: String, seed: Int) -> Int