LIBMURMURHASH(3)
π LIBMURMURHASH β the manual page, but make it slay π
okay so bestie, welcome to libmurmurhash(3), straight out of the libmurmurhash manual πβ¨. This is your girl explaining non-cryptographic hash functions to you like we're texting at 2am. Buckle up, it's giving very technical but also very cute. π
β¨ NAME β¨
libmurmurhash β non-cryptographic hash functions π₯
like... it hashes your bytes, but it is NOT for keeping secrets, okay? Not every hash has to be a bodyguard. π
πΈ SYNOPSIS πΈ
First things first, you gotta include the header, no cap:
#include <murmurhash.h>
Then here are the three icons themselves π:
void lmmh_x86_32(const void *addr, unsigned int len, uint32_t seed, uint32_t out[1]);
void lmmh_x86_128(const void *addr, unsigned int len, uint32_t seed, uint32_t out[4]);
void lmmh_x64_128(const void *addr, unsigned int len, uint32_t seed, uint64_t out[2]);
π Deprecated API π
These ones still exist but they're giving "nostalgia post from 2014". They are deprecated, bestie, don't start anything new with them:
void MurmurHash3_x86_32(const void *data, int len, uint32_t seed, void *out);
void MurmurHash3_x86_128(const void *data, int len, uint32_t seed, void *out);
void MurmurHash3_x64_128(const void *data, int len, uint32_t seed, void *out);
π¦ DESCRIPTION π¦
So. LibMurmurHash hands you all three variants of MurmurHash3, taken straight from the original source. No remixes, no edits, the original audio. π§
Let's break the params down because the way that each one matters:
addrβ the very first parameter, and it points to where your data starts in memory. The beginning. The main character's entrance. β¨lenβ the second parameter, and it's literally just how many bytes you want hashed. Count them. Be precise. π’seedβ the third parameter, and this one's fun: you can use it to compute a completely different hash over the exact same data. Same bytes, different seed, different vibe. π²outβ and finally you pass the location where the hash should be written. It writes there. That's it. That's the whole thing. π«Ά
π EXAMPLE π
Say you wanna compute the hash of length bytes starting from data, and then print that 32-bit sized hash value. Iconic, let's go:
uint32_t hash;
lmmh_x86_32(data, length, 0, &hash);
printf("%" PRIx32 "", hash);
And now the same thing but wider, because sometimes you want more hash per hash. Bigger. Bolder. π
uint64_t widehash[2];
lmmh_x64_128(data, length, 0, widehash);
printf("%" PRIx64 "%" PRIx64 "", widehash[0], widehash[1]);
π AUTHORS π
Credit where credit is due, always, fr fr:
- MurmurHash was created by Austin Appleby.
- PMurHash was written by Shane Day.
- libmurmurhash was created by Fabian KlΓΆtzl.
And get this β all code is dedicated to the public domain. Free. For everyone. Periodt. π
π BUGS π
Okay so the old API is problematic and I need you to hear me on this:
- a negative
lenstays unchecked π like it will not stop you, it will simply not look - the output parameter has very specific alignment requirements β οΈ so line it up correctly or perish
- and on top of all that, the order of bytes in the hash may differ across architectures π so don't go assuming it looks the same everywhere
Not me warning you about undefined-adjacent chaos in a manpage. But like. I warned you. π
π Reporting Bugs π
Found something? Please file a bug on GitHub at github.com/kloetzl/libmurmurhash or send a mail to fabian-libmurmurhash@kloetzl.info. They wanna hear from you, bestie, don't be shy. π
and that's the whole page, you ate it, you understood it, you're a Unix girlie now πβ¨π¦πΈ
This was libmurmurhash, version 1, dated 2019-02-04 β the libmurmurhash manual. Byeeee, go hash something responsibly π«Άπ
π¦ where this page comes from
- debian bookworm: libmurmurhash-dev 1.5-3 Β· LicenseRef-public-domain
- debian trixie: libmurmurhash-dev 1.6-1+b1 Β· LicenseRef-public-domain
- ubuntu jammy: libmurmurhash-dev 1.5-3 Β· LicenseRef-public-domain
- ubuntu noble: libmurmurhash-dev 1.6-1 Β· LicenseRef-public-domain
- ubuntu questing: libmurmurhash-dev 1.6-1
- ubuntu resolute: libmurmurhash-dev 1.6-1build1 Β· LicenseRef-public-domain
- ubuntu stonking: libmurmurhash-dev 1.6-1build1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms