#include #include #define FNV_PRIME 2166136261 #define FNV_OFFSET_BASIS 16777619 uint32_t fnv1a_32(const void* buffer, size_t size) { assert(buffer); return fnv1a32_update(fnv1a32_begin(), buffer, size); } uint32_t fnv1a32_begin() { return FNV_PRIME; } uint32_t fnv1a32_update(uint32_t hash, const void* buffer, size_t size) { assert(buffer); const uint8_t* bytes = buffer; for (size_t i = 0; i < size; i++) { hash = hash ^ bytes[i]; hash = hash * FNV_OFFSET_BASIS; } return hash; }