- Swift wrapper for polymur-hash
- Declare dependency in Package.swift,
Package(...,
:dependencies:
.package(url: "https://github.com/wti/SwiftPolymurHash.git", from: "0.0.1")
targets: [ .target(..., dependencies:
[.product(name: "PolymurHash", package: "SwiftPolymurHash")]
- Code
- See e.g., PolymurHashTests
- The tweak value provides some pseudo-variance to avoid hash attacks
- But you can set it to zero or the same value to reproduce hashes
- It uses 5 UInt64's of state per hasher (including the default tweak value)
- Swift is not amenable to extrinsic hashing
- Hashable.hashValue is deprecated
- Hasher has no API for extrinsic values
- There are no guarantees that polymur hashes will combine well with Swift hashes
- Consider restricting usage for Hashable to top-level types
- See SE-206
- polymur-hash.h is manually copied from its source repository
- also demo.c is from main.c, with main function renamed
- Update PolymurHash.VERSION in swift when updating sources
- Compiling: 2 known warnings
- test code deprecation for
Hashable.hashValue
- c code
Implicit conversion loses integer precision
- test code deprecation for
- Linking
- No need to link with m (math) library on Linux, et al?
linkerSettings: [.linkedLibrary("m", .when(platforms: [.linux]))]
- No need to link with m (math) library on Linux, et al?
- Testing
- TODO: verify swift compiler reduces to same/similar assembly as clang
- Copyright authors, All Rights Reserved
- polymur-hash is subject to its license and copyright
- This wrapper project is released under an MIT license.