
Implements SHA-3 hash functions, offering standard API, HashInputStream, HashOutputStream, and derived hash functions like cSHAKE and KMAC. Extends capabilities with byte streamable and extendable functions.
This is a Kotlin Multiplatform implementation of SHA-3 with a shared Kotlin core. JVM, JavaScript, and WebAssembly use the Kotlin implementation. Native targets use KeccakRust for the permutation through a static C ABI bridge. (This would likely grow so that all APIs for native targets/platforms use KeccakRust. This will significantly improve performance in native targets/platforms.)
This is used in KyberKotlin, an ML-KEM implemention of NIST FIPS 203.
[!WARNING] 2.6.0 is currently experimental. If you build from this source, you are building with the new KeccakRust permutation backend.
[!NOTE] 2.3.0 is a maintenance release. It is essentially 2.1.1 but additionally supports linuxArm64, iosX64, iosArm64, and iosSimulatorArm64 as well as Kotlin 2.4.20 and Gradle 9.7.1.
[!WARNING] 2.3.0 and 2.4.0-alpha broke binary compatibility with Java <21. 2.5.0 restores compatibility to Java 8.
[!NOTE] These hash functions will be gradually implemented.
ParallelHash Functions might need to add coroutine as a dependency.
| Target +(JS/WASM)** | Arm32 | Arm64 | X64 |
|---|---|---|---|
| JVM (Kotlin & Java) | |||
| Linux | ❌ * | ||
| Windows (Mingw) | ❌ * | ❌ * | |
| Android | ✅ | ✅ | ✅ |
| iOS | ❌ * | ||
| iOS Simulator | ❌ * | ❌ * |
*Note: Some platforms are unavailable/deprecated as targets in Kotlin Multiplatform. Please send your complaints to Jetbrains.
**JavaScript and WebAssembly(WASM) are always tested alongside the JVM test, so their results are tied together.
Maven/Gradle
dependencies {
implementation("asia.hombre:keccak:<version>") // asia.hombre:keccak:2.5.1
}Please see the releases for the latest version.
See more installation instructions here.
val sha3_224 = SHA3_224().digest()
println(sha3_224.toHexString(HexFormat.UpperCase))
val sha3_256 = SHA3_256().digest()
println(sha3_256.toHexString(HexFormat.UpperCase))
val sha3_384 = SHA3_384().digest()
println(sha3_384.toHexString(HexFormat.UpperCase))
val sha3_512 = SHA3_512().digest()
println(sha3_512.toHexString(HexFormat.UpperCase))
val kmac_128 = KMAC128("key".encodeToByteArray(), 32).digest()
println(kmac_128.toHexString(HexFormat.UpperCase))
val kmac_256 = KMAC256("key".encodeToByteArray(), 64).digest()
println(kmac_256.toHexString(HexFormat.UpperCase))
//Extendable-Output Functions
val rawshake_128 = RawSHAKE128().digest()
println(rawshake_128.toHexString(HexFormat.UpperCase))
val rawshake_256 = RawSHAKE256().digest()
println(rawshake_256.toHexString(HexFormat.UpperCase))
val shake_128 = SHAKE128().digest()
println(shake_128.toHexString(HexFormat.UpperCase))
val shake_256 = SHAKE256().digest()
println(shake_256.toHexString(HexFormat.UpperCase))
val cshake_128 = cSHAKE128().digest()
println(cshake_128.toHexString(HexFormat.UpperCase))
val cshake_256 = cSHAKE256().digest()
println(cshake_256.toHexString(HexFormat.UpperCase))
val kmacxof_128 = KMACXOF128("key".encodeToByteArray()).digest()
println(kmacxof_128.toHexString(HexFormat.UpperCase))
val kmacxof_256 = KMACXOF256("key".encodeToByteArray()).digest()
println(kmacxof_256.toHexString(HexFormat.UpperCase))
//Input Streaming
val shake128_in = SHAKE128.newInputStream()
shake128_in.write("Hello!".encodeToByteArray())
//Output Streaming
val shake128_out = shake128_in.close()
println(shake128_out.nextBytes(1024).toHexString(HexFormat.UpperCase))View the java example here!
Copyright 2026 Ron Lauren Hombre
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
and included as LICENSE.txt in this Project.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Although SHA-3 is Public Domain, this implementation is created through Hard Work by its Contributors. Thus, the APACHE LICENSE v2.0 has been chosen.
This is a Kotlin Multiplatform implementation of SHA-3 with a shared Kotlin core. JVM, JavaScript, and WebAssembly use the Kotlin implementation. Native targets use KeccakRust for the permutation through a static C ABI bridge. (This would likely grow so that all APIs for native targets/platforms use KeccakRust. This will significantly improve performance in native targets/platforms.)
This is used in KyberKotlin, an ML-KEM implemention of NIST FIPS 203.
[!WARNING] 2.6.0 is currently experimental. If you build from this source, you are building with the new KeccakRust permutation backend.
[!NOTE] 2.3.0 is a maintenance release. It is essentially 2.1.1 but additionally supports linuxArm64, iosX64, iosArm64, and iosSimulatorArm64 as well as Kotlin 2.4.20 and Gradle 9.7.1.
[!WARNING] 2.3.0 and 2.4.0-alpha broke binary compatibility with Java <21. 2.5.0 restores compatibility to Java 8.
[!NOTE] These hash functions will be gradually implemented.
ParallelHash Functions might need to add coroutine as a dependency.
| Target +(JS/WASM)** | Arm32 | Arm64 | X64 |
|---|---|---|---|
| JVM (Kotlin & Java) | |||
| Linux | ❌ * | ||
| Windows (Mingw) | ❌ * | ❌ * | |
| Android | ✅ | ✅ | ✅ |
| iOS | ❌ * | ||
| iOS Simulator | ❌ * | ❌ * |
*Note: Some platforms are unavailable/deprecated as targets in Kotlin Multiplatform. Please send your complaints to Jetbrains.
**JavaScript and WebAssembly(WASM) are always tested alongside the JVM test, so their results are tied together.
Maven/Gradle
dependencies {
implementation("asia.hombre:keccak:<version>") // asia.hombre:keccak:2.5.1
}Please see the releases for the latest version.
See more installation instructions here.
val sha3_224 = SHA3_224().digest()
println(sha3_224.toHexString(HexFormat.UpperCase))
val sha3_256 = SHA3_256().digest()
println(sha3_256.toHexString(HexFormat.UpperCase))
val sha3_384 = SHA3_384().digest()
println(sha3_384.toHexString(HexFormat.UpperCase))
val sha3_512 = SHA3_512().digest()
println(sha3_512.toHexString(HexFormat.UpperCase))
val kmac_128 = KMAC128("key".encodeToByteArray(), 32).digest()
println(kmac_128.toHexString(HexFormat.UpperCase))
val kmac_256 = KMAC256("key".encodeToByteArray(), 64).digest()
println(kmac_256.toHexString(HexFormat.UpperCase))
//Extendable-Output Functions
val rawshake_128 = RawSHAKE128().digest()
println(rawshake_128.toHexString(HexFormat.UpperCase))
val rawshake_256 = RawSHAKE256().digest()
println(rawshake_256.toHexString(HexFormat.UpperCase))
val shake_128 = SHAKE128().digest()
println(shake_128.toHexString(HexFormat.UpperCase))
val shake_256 = SHAKE256().digest()
println(shake_256.toHexString(HexFormat.UpperCase))
val cshake_128 = cSHAKE128().digest()
println(cshake_128.toHexString(HexFormat.UpperCase))
val cshake_256 = cSHAKE256().digest()
println(cshake_256.toHexString(HexFormat.UpperCase))
val kmacxof_128 = KMACXOF128("key".encodeToByteArray()).digest()
println(kmacxof_128.toHexString(HexFormat.UpperCase))
val kmacxof_256 = KMACXOF256("key".encodeToByteArray()).digest()
println(kmacxof_256.toHexString(HexFormat.UpperCase))
//Input Streaming
val shake128_in = SHAKE128.newInputStream()
shake128_in.write("Hello!".encodeToByteArray())
//Output Streaming
val shake128_out = shake128_in.close()
println(shake128_out.nextBytes(1024).toHexString(HexFormat.UpperCase))View the java example here!
Copyright 2026 Ron Lauren Hombre
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
and included as LICENSE.txt in this Project.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Although SHA-3 is Public Domain, this implementation is created through Hard Work by its Contributors. Thus, the APACHE LICENSE v2.0 has been chosen.