36 lines
788 B
Markdown
36 lines
788 B
Markdown
# kdf-kt
|
|
|
|
`kdf-kt` is a Kotlin Multiplatform library that provides common [Key Derivation Functions](https://en.wikipedia.org/wiki/Key_derivation_function).
|
|
|
|
Supported algorithms:
|
|
- PBKDF2
|
|
|
|
## 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.2.0")
|
|
}
|
|
```
|
|
|
|
## Usage
|
|
|
|
```kotlin
|
|
fun main() {
|
|
// create a PBKDF2 instance using HMAC SHA-256
|
|
// this example uses 32 bytes of length and 100_000 iterations
|
|
val kdf = PBKDF2(32, 100_000, `SHA-256`)
|
|
|
|
// securely hash value with some salt
|
|
val value = "password".encodeToByteArray()
|
|
val salt = "salt".encodeToByteArray()
|
|
val hash = kdf.hash(value, salt)
|
|
}
|
|
```
|