44 lines
894 B
Markdown
44 lines
894 B
Markdown
# Kotlin MAC
|
|
|
|
This library provides various [Message Authentication Code](https://en.wikipedia.org/wiki/Message_authentication_code) implementations in Kotlin Multiplatform.
|
|
|
|
## Features
|
|
|
|
* Generate message authentication codes.
|
|
* [HMAC](https://en.wikipedia.org/wiki/HMAC)
|
|
* 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:mac:1.2.2")
|
|
}
|
|
```
|
|
|
|
## Usage
|
|
|
|
```kotlin
|
|
import com.infendro.hash.SHA1
|
|
import com.infendro.mac.HMAC
|
|
|
|
fun main() {
|
|
// create an HMAC instance using SHA1
|
|
val hmac = HMAC(SHA1)
|
|
|
|
// generate MAC
|
|
val key = "secret".encodeToByteArray()
|
|
val value = "Hello World!".encodeToByteArray()
|
|
val mac = hmac.hash(key, value)
|
|
}
|
|
```
|