xxHash framework in Swift
xxHash-Swift
xxHash framework in Swift. Original xxHash algorithm created by Yann Collet.
Currently only suppport XXH3-64.
It currently points to the upstream v0.8.1
Requirements
- Swift 5.0
Installation
- Using Swift Package Manager
Usage
import xxHash_Swift
Generate one-shot digest
let digest = XXH3.digest64("Input String")
let digest = XXH3.digest64(Data())
Generate digest by streaming
- non-async
let digest = try XXH3.digest64 { state in
for data in dataProducer {
try state.update(data)
}
}
return String(digest, radix: 16, uppercase: true)
- async
let digest = try await XXH3.digest64 { state in
for try await data in dataProducer {
try state.update(data)
}
}
return String(digest, radix: 16, uppercase: true)
Contribution
Update with upstream version
- Checkout upstream code with a new version, e.g. v0.8.2
git -C Sources/xxHash/xxHash checkout v0.8.2
- Update Sources and Tests if needed
- Update README if needed
- Tag with a new version accoring to Semantic Versioning 2.0.0
Update Swift Package Tools Version
- Update
Package.swift
manifest, according to Setting the Swift Tools Version
For example, if we want to set the tools version to 5.5
swift package tools-version --set 5.5
- Update
README
with Swift requirements - Run test
Add more test according to upstream test data
Add more hash algorithm supported in the upstream
License
The library is BSD licensed, which has the same as the upstream.