mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-13 11:20:20 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a03f7201d2 | |||
94e26ee8a0 | |||
2d8ad47083 | |||
e9aec238a1 | |||
844c33166c | |||
cfe9f2159f | |||
61bccd5f48 | |||
e5a608a315 | |||
9b4f35eea1 |
16
.github/workflows/gradle_build.yml
vendored
Normal file
16
.github/workflows/gradle_build.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Build
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,5 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## 0.4.23
|
||||
|
||||
* `Versions`:
|
||||
* `Ktor`: `1.5.0` -> `1.5.1`
|
||||
* `Serialization`
|
||||
* `Base64`
|
||||
* New serializer `Base64BytesToFromStringSerializer` has been added
|
||||
|
||||
## 0.4.22
|
||||
|
||||
* `Versions`:
|
||||
* `Exposed`: `0.28.1` -> `0.29.1`
|
||||
* `Klock`: `2.0.2` -> `2.0.4`
|
||||
|
||||
## 0.4.21
|
||||
|
||||
* `Common`
|
||||
|
@@ -9,11 +9,11 @@ android.enableJetifier=true
|
||||
kotlin_version=1.4.21
|
||||
kotlin_coroutines_version=1.4.2
|
||||
kotlin_serialisation_core_version=1.0.1
|
||||
kotlin_exposed_version=0.28.1
|
||||
kotlin_exposed_version=0.29.1
|
||||
|
||||
ktor_version=1.5.0
|
||||
ktor_version=1.5.1
|
||||
|
||||
klockVersion=2.0.2
|
||||
klockVersion=2.0.4
|
||||
|
||||
github_release_plugin_version=2.2.12
|
||||
|
||||
@@ -44,5 +44,5 @@ dokka_version=1.4.20
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.4.21
|
||||
android_code_version=25
|
||||
version=0.4.23
|
||||
android_code_version=27
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.micro_utils.serialization.base64
|
||||
|
||||
import dev.inmo.micro_utils.crypto.*
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* Converts [ByteArray] into base64 encoded string due to serialization and decode base64 encoded string into bytes
|
||||
*/
|
||||
object Base64BytesToFromStringSerializer: KSerializer<ByteArray> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
override fun deserialize(decoder: Decoder): SourceBytes = decoder.decodeString().decodeBase64()
|
||||
override fun serialize(encoder: Encoder, value: SourceBytes) = encoder.encodeString(value.encodeBase64String())
|
||||
}
|
@@ -1,9 +1,6 @@
|
||||
package dev.inmo.micro_utils.serialization.base64
|
||||
|
||||
import dev.inmo.micro_utils.crypto.*
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
@@ -12,9 +9,9 @@ open class Base64Serializer<T>(
|
||||
private val converterFrom: (T) -> String,
|
||||
private val converterTo: (String) -> T,
|
||||
) : KSerializer<T> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
override fun deserialize(decoder: Decoder): T = converterTo(decoder.decodeString().decodeBase64String())
|
||||
override fun serialize(encoder: Encoder, value: T) = encoder.encodeString(converterFrom(value).encodeBase64String())
|
||||
override val descriptor: SerialDescriptor = Base64BytesToFromStringSerializer.descriptor
|
||||
override fun deserialize(decoder: Decoder): T = converterTo(Base64BytesToFromStringSerializer.deserialize(decoder).decodeToString())
|
||||
override fun serialize(encoder: Encoder, value: T) = Base64BytesToFromStringSerializer.serialize(encoder, converterFrom(value).encodeToByteArray())
|
||||
}
|
||||
|
||||
object Base64StringSerializer : Base64Serializer<String>({ it }, { it })
|
||||
|
Reference in New Issue
Block a user