Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Data Extension for Fowler–Noll–Vo hash function
import Foundation
extension Data {
public var fnv32Hash: UInt32 {
return UInt32( self.reduce(0x811c9dc5) { 0x00000000FFFFFFFF & ($0 * 16777619) ^ UInt64($1) } )
}
public func fnv32HashString() -> String {
return String(format: "%08x", self.fnv32Hash)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.