Compare commits
3 Commits
bd5d904a3b
...
688beb61b9
| Author | SHA1 | Date | |
|---|---|---|---|
|
688beb61b9
|
|||
|
21858641e5
|
|||
|
704cf2a796
|
@@ -4,7 +4,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GIT__TOKEN: ${{ secrets.TOKEN }}
|
INFENDRO__TOKEN: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
|
|||||||
38
README.md
38
README.md
@@ -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.
|
## Targets
|
||||||
* Binary
|
|
||||||
* Hex
|
| Target | Status |
|
||||||
* Base32
|
|------------------|---------------|
|
||||||
* Base64
|
| JVM | Supported |
|
||||||
* Multiplatform support
|
| JavaScript | Supported |
|
||||||
* JVM
|
| Native (Linux) | Supported |
|
||||||
* JavaScript
|
| Native (Windows) | Not Supported |
|
||||||
* Native (Linux)
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -24,21 +28,23 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.infendro:encoding:1.1.0")
|
implementation("com.infendro:encoding:1.2.0")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import com.infendro.encoding.Hex
|
import com.infendro.encoding.Base16
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
// the string to encode
|
// the string to encode
|
||||||
val test = "Hello World!".encodeToByteArray()
|
val test = "Hello World!"
|
||||||
|
.encodeToByteArray().asUByteArray()
|
||||||
|
|
||||||
// encode the string with the desired encoding
|
// encode the string with the desired encoding
|
||||||
val encoded = Hex.encode(test).decodeToString()
|
val encoded = Base16.encode(test)
|
||||||
|
.asByteArray().decodeToString()
|
||||||
|
|
||||||
println(encoded) // 48656c6c6f20576f726c6421
|
println(encoded) // 48656c6c6f20576f726c6421
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
|
import com.infendro.plugin.infendro
|
||||||
|
import com.infendro.plugin.token
|
||||||
|
|
||||||
group = "com.infendro"
|
group = "com.infendro"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
alias(libs.plugins.infendro)
|
||||||
alias(libs.plugins.multiplatform)
|
alias(libs.plugins.multiplatform)
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,10 @@ kotlin {
|
|||||||
}
|
}
|
||||||
linuxX64()
|
linuxX64()
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonTest.dependencies {
|
commonTest.dependencies {
|
||||||
implementation(libs.test)
|
implementation(libs.test)
|
||||||
@@ -28,31 +32,6 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing.repositories {
|
||||||
repositories {
|
infendro(token)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[versions]
|
[versions]
|
||||||
kotlin = "2.1.20"
|
infendro = "1.0.0"
|
||||||
|
kotlin = "2.2.21"
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
infendro = { id = "com.infendro.plugin", version.ref = "infendro" }
|
||||||
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
rootProject.name = "encoding"
|
rootProject.name = "encoding"
|
||||||
|
|
||||||
|
pluginManagement.repositories {
|
||||||
|
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user