diff --git a/src/libs/murmur3/example.c b/src/libs/murmur3/example.c new file mode 100644 index 0000000..ca041a3 --- /dev/null +++ b/src/libs/murmur3/example.c @@ -0,0 +1,32 @@ +/* Murmur3 example: hash the first command line argument. */ + +#include +#include +#include +#include +#include "murmur3.h" + +int main(int argc, char **argv) { + uint32_t hash[4]; /* Output for the hash */ + uint32_t seed = 420; /* Seed value for hash */ + + if (argc != 2) { + printf("usage: %s \"string to hash\"\n", argv[0]); + exit(1); + } + + printf("Input: \"%s\"\n", argv[1]); + + MurmurHash3_x86_32(argv[1], strlen(argv[1]), seed, hash); + printf("x86_32: %08x\n", hash[0]); + + MurmurHash3_x86_128(argv[1], strlen(argv[1]), seed, hash); + printf("x86_128: %08x %08x %08x %08x\n", + hash[0], hash[1], hash[2], hash[3]); + + MurmurHash3_x64_128(argv[1], strlen(argv[1]), seed, hash); + printf("x64_128: %08x %08x %08x %08x\n", + hash[0], hash[1], hash[2], hash[3]); + + return 0; +} \ No newline at end of file