Created
September 26, 2012 07:39
-
-
Save rasmuskl/3786618 to your computer and use it in GitHub Desktop.
FNV 1a 64-bit C# non-cryptographic hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FNV-1a (64-bit) non-cryptographic hash function. | |
// Adapted from: http://github.com/jakedouglas/fnv-java | |
public ulong HashFNV1a(byte[] bytes) | |
{ | |
const ulong fnv64Offset = 14695981039346656037; | |
const ulong fnv64Prime = 0x100000001b3; | |
ulong hash = fnv64Offset; | |
for (var i = 0; i < bytes.Length; i++) | |
{ | |
hash = hash ^ bytes[i]; | |
hash *= fnv64Prime; | |
} | |
return hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this under the same license as https://github.com/jakedouglas/fnv-java ?