diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-10-13 22:10:38 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-10-13 22:10:38 +0200 |
| commit | 733f01be8c2ca986e594816e73cb89ee1c8d105d (patch) | |
| tree | 7709f194f714b0bcfdbab0c65ec5aa7b3fe49c14 /src/main/kotlin/util/Base64Util.kt | |
| parent | 05160314e6899ece75779dbd2e5b691ed581c2b9 (diff) | |
| download | Firmament-733f01be8c2ca986e594816e73cb89ee1c8d105d.tar.gz Firmament-733f01be8c2ca986e594816e73cb89ee1c8d105d.tar.bz2 Firmament-733f01be8c2ca986e594816e73cb89ee1c8d105d.zip | |
feat: remove ktor (for a smaller binary)
Diffstat (limited to 'src/main/kotlin/util/Base64Util.kt')
| -rw-r--r-- | src/main/kotlin/util/Base64Util.kt | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/kotlin/util/Base64Util.kt b/src/main/kotlin/util/Base64Util.kt index c39c601..0b7b3ea 100644 --- a/src/main/kotlin/util/Base64Util.kt +++ b/src/main/kotlin/util/Base64Util.kt @@ -1,17 +1,23 @@ - package moe.nea.firmament.util import java.util.Base64 object Base64Util { fun decodeString(str: String): String { + return decodeBytes(str).decodeToString() + } + + fun decodeBytes(str: String): ByteArray { return Base64.getDecoder().decode(str.padToValidBase64()) - .decodeToString() } - fun String.padToValidBase64(): String { - val align = this.length % 4 - if (align == 0) return this - return this + "=".repeat(4 - align) - } + fun String.padToValidBase64(): String { + val align = this.length % 4 + if (align == 0) return this + return this + "=".repeat(4 - align) + } + + fun encodeToString(bytes: ByteArray): String { + return Base64.getEncoder().encodeToString(bytes) + } } |
