diff --git a/README.md b/README.md index 61c4a33..23c1d1f 100644 --- a/README.md +++ b/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. - * [HMAC](https://en.wikipedia.org/wiki/HMAC) -* Multiplatform support - * JVM - * JavaScript - * Native (Linux) +## Targets + +| Target | Status | +|------------------|---------------| +| JVM | Supported | +| JavaScript | Supported | +| Native (Linux) | Supported | +| Native (Windows) | Not Supported | ## Installation @@ -21,14 +24,14 @@ repositories { } dependencies { - implementation("com.infendro:mac:1.2.2") + implementation("com.infendro:mac:1.2.0") } ``` ## Usage ```kotlin -import com.infendro.hash.SHA1 +import com.infendro.hash.sha1.SHA1 import com.infendro.mac.HMAC fun main() { @@ -36,8 +39,10 @@ fun main() { val hmac = HMAC(SHA1) // generate MAC - val key = "secret".encodeToByteArray() - val value = "Hello World!".encodeToByteArray() + val key = "secret" + .encodeToByteArray().asUByteArray() + val value = "Hello World!" + .encodeToByteArray().asUByteArray() val mac = hmac.hash(key, value) } ``` diff --git a/src/commonTest/kotlin/com/infendro/mac/HMAC.kt b/src/commonTest/kotlin/com/infendro/mac/HMAC.kt index a6f404e..e47ab4b 100644 --- a/src/commonTest/kotlin/com/infendro/mac/HMAC.kt +++ b/src/commonTest/kotlin/com/infendro/mac/HMAC.kt @@ -1,5 +1,6 @@ package com.infendro.mac +import com.infendro.bytearray.encodeToUByteArray import com.infendro.hash.sha2.`SHA-256` import kotlin.test.Test import kotlin.test.assertContentEquals @@ -28,8 +29,8 @@ class `HMAC Test` { 0x2dU, 0x1aU, 0x3cU, 0xd8U, ), hmac.hash( - "key".encodeToByteArray().asUByteArray(), - "The quick brown fox jumps over the lazy dog".encodeToByteArray().asUByteArray() + "key".encodeToUByteArray(), + "The quick brown fox jumps over the lazy dog".encodeToUByteArray() ) ) }