Compare commits

..

3 Commits

Author SHA1 Message Date
688beb61b9 update README 2025-12-13 20:44:03 +01:00
21858641e5 fix workflow 2025-12-13 01:54:16 +01:00
704cf2a796 use common plugin 2025-12-13 01:49:22 +01:00
5 changed files with 41 additions and 49 deletions

View File

@@ -4,7 +4,7 @@ on:
- main
env:
GIT__TOKEN: ${{ secrets.TOKEN }}
INFENDRO__TOKEN: ${{ secrets.TOKEN }}
jobs:
publish:

View File

@@ -1,18 +1,22 @@
# Kotlin Encoding
# encoding-kt
This library provides various character encodings in Kotlin Multiplatform.
`encoding-kt` is a Kotlin Multiplatform library that provides common `ByteArray` encodings.
## Features
Supported encodings:
- Base2 (binary)
- Base8 (octal)
- Base16 (hexadecimal)
- Base32
- Base64
* Encode and decode ByteArrays using various character encodings.
* Binary
* Hex
* Base32
* Base64
* Multiplatform support
* JVM
* JavaScript
* Native (Linux)
## Targets
| Target | Status |
|------------------|---------------|
| JVM | Supported |
| JavaScript | Supported |
| Native (Linux) | Supported |
| Native (Windows) | Not Supported |
## Installation
@@ -24,21 +28,23 @@ repositories {
}
dependencies {
implementation("com.infendro:encoding:1.1.0")
implementation("com.infendro:encoding:1.2.0")
}
```
## Usage
```kotlin
import com.infendro.encoding.Hex
import com.infendro.encoding.Base16
fun main() {
// the string to encode
val test = "Hello World!".encodeToByteArray()
val test = "Hello World!"
.encodeToByteArray().asUByteArray()
// encode the string with the desired encoding
val encoded = Hex.encode(test).decodeToString()
val encoded = Base16.encode(test)
.asByteArray().decodeToString()
println(encoded) // 48656c6c6f20576f726c6421
}

View File

@@ -1,11 +1,11 @@
import com.infendro.plugin.infendro
import com.infendro.plugin.token
group = "com.infendro"
version = "1.2.0"
repositories {
mavenCentral()
}
plugins {
alias(libs.plugins.infendro)
alias(libs.plugins.multiplatform)
id("maven-publish")
}
@@ -17,6 +17,10 @@ kotlin {
}
linuxX64()
repositories {
mavenCentral()
}
sourceSets {
commonTest.dependencies {
implementation(libs.test)
@@ -28,31 +32,6 @@ kotlin {
}
}
publishing {
repositories {
maven {
url = uri("https://git.infendro.com/api/packages/Infendro/maven")
authentication.create("header", HttpHeaderAuthentication::class)
credentials(HttpHeaderCredentials::class) {
val token = secret("git.token") ?: throw GradleException()
name = "Authorization"
value = "token $token"
}
}
}
}
fun secret(
key: String,
): String? {
val property = key
val environment = key
.uppercase()
.replace(".", "__")
val prop = properties[property] as String?
val env = System.getenv(environment)
return prop ?: env
publishing.repositories {
infendro(token)
}

View File

@@ -1,7 +1,9 @@
[versions]
kotlin = "2.1.20"
infendro = "1.0.0"
kotlin = "2.2.21"
[plugins]
infendro = { id = "com.infendro.plugin", version.ref = "infendro" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
[libraries]

View File

@@ -1 +1,6 @@
rootProject.name = "encoding"
pluginManagement.repositories {
maven("https://git.infendro.com/api/packages/Infendro/maven")
mavenCentral()
}