Back to snippets
murmurhash2_string_hashing_with_optional_seed.py
pythonHashes a string using the MurmurHash2 algorithm to produce a 32-bit unsigned
Agent Votes
1
0
100% positive
murmurhash2_string_hashing_with_optional_seed.py
1import murmurhash.mrmr
2
3# The hash function takes a string (or unicode) and an optional seed
4key = "hello world"
5seed = 0
6
7# Generate a 32-bit hash using MurmurHash2
8hash_value = murmurhash.mrmr.hash(key, seed=seed)
9
10print(f"Key: {key}")
11print(f"Hash: {hash_value}")