--- /dev/null
+/*
+Copyright (C) 2018 Keziah Wesley
+
+You can redistribute and/or modify this file under the terms of the
+GNU Affero General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this file. If not, see
+<http://www.gnu.org/licenses/>.
+*/
+
+#ifndef HASH_H
+#define HASH_H
+
+#include <stddef.h>
+
+// Very fast, non collision-resistant hash
+
+inline static uint32_t
+fnv_32a_init ()
+{
+ return 0x811c9dc5;
+}
+
+inline static uint32_t
+fnv_32a_extend (const void *buf, size_t len, uint32_t hval)
+{
+ unsigned char *bp = (unsigned char *) buf;
+ unsigned char *be = bp + len;
+ while (bp < be)
+ {
+ hval ^= (uint32_t) * bp++;
+ /* multiply by the 32 bit FNV magic prime mod 2^32 */
+ hval +=
+ (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
+ }
+ return hval;
+}
+
+#endif // HASH_H