FNV-1a (Fowler–Noll–Vo) hash function

#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t hash = 14695981039346656037ULL;
	for (char c = getchar(); c != EOF; c = getchar()) {
		hash = (hash ^ c) * 1099511628211ULL;
	}
	printf("%" PRIu64 "\n", hash);
	return 0;
}

Constants

FNV seed


FNV prime


Sources