Skip to content

Instantly share code, notes, and snippets.

@mgd020
Created October 29, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgd020/b31a1fbfc474114651c022ec6566aa24 to your computer and use it in GitHub Desktop.
Save mgd020/b31a1fbfc474114651c022ec6566aa24 to your computer and use it in GitHub Desktop.
fnv1a_128_prime = 309485009821345068724781371
fnv1a_128_offset = 144066263297769815596495629667062367629
fnv1a_128_mask = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
def fnv1a_128(bs):
h = fnv1a_offset
for b in bs:
h ^= b
h *= fnv1a_prime
h %= fnv1a_128_mask
return h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment