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

Usage

import xxHash_Swift

Generate one-shot digest

let digest = XXH3.digest64("Input String")

let digest = XXH3.digest64(Data())

Generate digest by streaming

  1. non-async

let digest = try XXH3.digest64 { state in
    for data in dataProducer {
        try state.update(data)
    }
}
return String(digest, radix: 16, uppercase: true)
  1. 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

  1. Checkout upstream code with a new version, e.g. v0.8.2
git -C Sources/xxHash/xxHash checkout v0.8.2
  1. Update Sources and Tests if needed
  2. Update README if needed
  3. Tag with a new version accoring to Semantic Versioning 2.0.0

Update Swift Package Tools Version

  1. 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
  1. Update README with Swift requirements
  2. Run test

Add more test according to upstream test data

Test data reference

Add more hash algorithm supported in the upstream

Reference file

License

The library is BSD licensed, which has the same as the upstream.

GitHub

View Github