fast-xxhash-kmp
2.0.1indexedHigh-performance xxHash implementations (XXH32, XXH64, XXH3_64bits, XXH3_128bits) with consistent API, native C-backed fast paths, pure fallback implementations, seeded and slice hashing support.
High-performance xxHash implementations (XXH32, XXH64, XXH3_64bits, XXH3_128bits) with consistent API, native C-backed fast paths, pure fallback implementations, seeded and slice hashing support.
Kotlin Multiplatform Library for xxHash with support for Android, JVM, iOS, JS, and Wasm.
The core library is in :lib. This repository also includes demo apps for Android, iOS, and Web, plus a shared Compose UI module.
XXH32, XXH64, XXH3_64bits, XXH3_128bitslib_android_native/src/main/cpp/xxhash.cxxhash C sources through Kotlin/Native cinteroporg.lz4:lz4-java and net.openhft:zero-allocation-hashinglib/src/webMain/kotlin/io/github/limuyang2/xxhash/libThe public API is consistent, but the JVM and Web implementations are not exactly the same.
dependencies {
implementation("io.github.limuyang2:xxhash:<latest-version>")
}
Maven Central:
io.github.limuyang2:xxhashio.github.limuyang2:xxhash-androidio.github.limuyang2:xxhash-jvmio.github.limuyang2:xxhash-jsio.github.limuyang2:xxhash-wasm-jsThe root xxhash artifact is the normal entry point for KMP projects.
import io.github.limuyang2.xxhash.lib.xxh32
import io.github.limuyang2.xxhash.lib.xxh64
import io.github.limuyang2.xxhash.lib.xxh3As64
import io.github.limuyang2.xxhash.lib.xxh3As128
val text = "Hello, World!"
val h32 = text.xxh32()
val h64 = text.xxh64()
val h3_64 = text.xxh3As64()
val h3_128 = text.xxh3As128()
bytes = text.encodeToByteArray()
slice = bytes.xxh32(offset = , length = )
seeded = bytes.xxh64(seed = )
All values are exposed as signed Kotlin Long. Treat them as unsigned when formatting or comparing against canonical xxHash hex output.
Android demo:
./gradlew :androidApp:installDebug
iOS demo:
./gradlew :commonApp:embedAndSignAppleFrameworkForXcode
Web demo:
./gradlew :webApp:jsBrowserDevelopmentWebpack
./gradlew :webApp:wasmJsBrowserDevelopmentWebpack
commonApp contains the shared Compose UI used by Android, iOS, and Web.
Library compile checks:
./gradlew :lib:compileKotlinJs
./gradlew :lib:compileKotlinWasmJs
./gradlew :lib:compileTestKotlinJs
Selected tests:
./gradlew :lib:jvmTest
./gradlew :lib:iosSimulatorArm64Test
./gradlew :lib:jsNodeTest
./gradlew :lib:wasmJsNodeTest
Some web tasks depend on the local Gradle/Node toolchain and your environment setup.
Useful paths:
lib/src/commonMain/kotlin/io/github/limuyang2/xxhash/liblib/src/webMain/kotlin/io/github/limuyang2/xxhash/liblib/src/iosMain/kotlin/io/github/limuyang2/xxhash/liblib/src/androidMain/kotlin/io/github/limuyang2/xxhash/liblib_android_native/src/main/cppMIT License
This repository includes xxHash source code. xxHash itself is distributed under the BSD 2-Clause License.
webMain| Method | Returns | Notes |
|---|
xxh32(input, seed) | Long | 32-bit hash in a Kotlin Long |
xxh32Bytes(input, offset, length, seed) | Long | slice hashing |
xxh64(input, seed) | Long | 64-bit hash |
xxh64Bytes(input, offset, length, seed) | Long | slice hashing |
xxh3_64bits(input) | Long | XXH3 64-bit |
xxh3_64bitsWithSeed(input, seed) | Long | XXH3 64-bit with seed |
xxh3_128bits(input) | LongArray | [low64, high64] |
xxh3_128bitsWithSeed(input, seed) | LongArray | [low64, high64] |
Surfaced from shared tags and platforms — no rankings paid for.