-
Notifications
You must be signed in to change notification settings - Fork 88
/
example.c
32 lines (24 loc) · 868 Bytes
/
example.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* Murmur3 example: hash the first command line argument. */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "murmur3.h"
int main(int argc, char **argv) {
uint32_t hash[4]; /* Output for the hash */
uint32_t seed = 42; /* 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;
}