
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_128bits
webMain
lib_android_native/src/main/cpp/xxhash.c
xxhash C sources through Kotlin/Native cinteroporg.lz4:lz4-java and net.openhft:zero-allocation-hashing
lib/src/webMain/kotlin/io/github/limuyang2/xxhash/lib
The 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() // longArrayOf(low64, high64)
val bytes = text.encodeToByteArray()
val slice = bytes.xxh32(offset = 7, length = 6)
val seeded = bytes.xxh64(seed = 42)| 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] |
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:installDebugiOS demo:
./gradlew :commonApp:embedAndSignAppleFrameworkForXcodeWeb demo:
./gradlew :webApp:jsBrowserDevelopmentWebpack
./gradlew :webApp:wasmJsBrowserDevelopmentWebpackcommonApp contains the shared Compose UI used by Android, iOS, and Web.
Library compile checks:
./gradlew :lib:compileKotlinJs
./gradlew :lib:compileKotlinWasmJs
./gradlew :lib:compileTestKotlinJsSelected tests:
./gradlew :lib:jvmTest
./gradlew :lib:iosSimulatorArm64Test
./gradlew :lib:jsNodeTest
./gradlew :lib:wasmJsNodeTestSome 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.
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_128bits
webMain
lib_android_native/src/main/cpp/xxhash.c
xxhash C sources through Kotlin/Native cinteroporg.lz4:lz4-java and net.openhft:zero-allocation-hashing
lib/src/webMain/kotlin/io/github/limuyang2/xxhash/lib
The 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() // longArrayOf(low64, high64)
val bytes = text.encodeToByteArray()
val slice = bytes.xxh32(offset = 7, length = 6)
val seeded = bytes.xxh64(seed = 42)| 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] |
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:installDebugiOS demo:
./gradlew :commonApp:embedAndSignAppleFrameworkForXcodeWeb demo:
./gradlew :webApp:jsBrowserDevelopmentWebpack
./gradlew :webApp:wasmJsBrowserDevelopmentWebpackcommonApp contains the shared Compose UI used by Android, iOS, and Web.
Library compile checks:
./gradlew :lib:compileKotlinJs
./gradlew :lib:compileKotlinWasmJs
./gradlew :lib:compileTestKotlinJsSelected tests:
./gradlew :lib:jvmTest
./gradlew :lib:iosSimulatorArm64Test
./gradlew :lib:jsNodeTest
./gradlew :lib:wasmJsNodeTestSome 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.