update README
This commit is contained in:
31
README.md
31
README.md
@@ -1,15 +1,18 @@
|
|||||||
# Kotlin MAC
|
# mac-kt
|
||||||
|
|
||||||
This library provides various [Message Authentication Code](https://en.wikipedia.org/wiki/Message_authentication_code) implementations in Kotlin Multiplatform.
|
`mac-kt` is a Kotlin Multiplatform library that provides common MAC implementations.
|
||||||
|
|
||||||
## Features
|
Supported MACs:
|
||||||
|
- HMAC
|
||||||
|
|
||||||
* Generate message authentication codes.
|
## Targets
|
||||||
* [HMAC](https://en.wikipedia.org/wiki/HMAC)
|
|
||||||
* Multiplatform support
|
| Target | Status |
|
||||||
* JVM
|
|------------------|---------------|
|
||||||
* JavaScript
|
| JVM | Supported |
|
||||||
* Native (Linux)
|
| JavaScript | Supported |
|
||||||
|
| Native (Linux) | Supported |
|
||||||
|
| Native (Windows) | Not Supported |
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -21,14 +24,14 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.infendro:mac:1.2.2")
|
implementation("com.infendro:mac:1.2.0")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import com.infendro.hash.SHA1
|
import com.infendro.hash.sha1.SHA1
|
||||||
import com.infendro.mac.HMAC
|
import com.infendro.mac.HMAC
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
@@ -36,8 +39,10 @@ fun main() {
|
|||||||
val hmac = HMAC(SHA1)
|
val hmac = HMAC(SHA1)
|
||||||
|
|
||||||
// generate MAC
|
// generate MAC
|
||||||
val key = "secret".encodeToByteArray()
|
val key = "secret"
|
||||||
val value = "Hello World!".encodeToByteArray()
|
.encodeToByteArray().asUByteArray()
|
||||||
|
val value = "Hello World!"
|
||||||
|
.encodeToByteArray().asUByteArray()
|
||||||
val mac = hmac.hash(key, value)
|
val mac = hmac.hash(key, value)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.infendro.mac
|
package com.infendro.mac
|
||||||
|
|
||||||
|
import com.infendro.bytearray.encodeToUByteArray
|
||||||
import com.infendro.hash.sha2.`SHA-256`
|
import com.infendro.hash.sha2.`SHA-256`
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertContentEquals
|
import kotlin.test.assertContentEquals
|
||||||
@@ -28,8 +29,8 @@ class `HMAC Test` {
|
|||||||
0x2dU, 0x1aU, 0x3cU, 0xd8U,
|
0x2dU, 0x1aU, 0x3cU, 0xd8U,
|
||||||
),
|
),
|
||||||
hmac.hash(
|
hmac.hash(
|
||||||
"key".encodeToByteArray().asUByteArray(),
|
"key".encodeToUByteArray(),
|
||||||
"The quick brown fox jumps over the lazy dog".encodeToByteArray().asUByteArray()
|
"The quick brown fox jumps over the lazy dog".encodeToUByteArray()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user