Files
kdf.kt/README.md
2025-10-04 11:58:28 +02:00

45 lines
959 B
Markdown

# Kotlin KDF
This library provides various [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)
implementations in Kotlin Multiplatform.
## Features
* [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2)
* Multiplatform support
* JVM
* JavaScript
* Native (Linux)
## Installation
Add the following to your `build.gradle.kts`.
```kotlin
repositories {
maven("https://git.infendro.com/api/packages/Infendro/maven")
}
dependencies {
implementation("com.infendro:kdf:1.0.3")
}
```
## Usage
```kotlin
import com.infendro.hash.SHA256
import com.infendro.kdf.PBKDF2
fun main() {
// create a PBKDF2 instance using HMAC SHA256
val kdf = PBKDF2(SHA256)
// securely hash value with some salt
// this example uses 100_000 iterations and 32 bytes of length
val value = "password".encodeToByteArray()
val salt = "...".encodeToByteArray()
val hash = kdf.hash(value, salt, 100_000, 32)
}
```