commonMain.io.eqoty.secretk.utils.UByteArrayUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client Show documentation
Show all versions of client Show documentation
A Kotlin multiplatform REST client utilizing secret network's gRPC gateway endpoints.
package io.eqoty.secretk.utils
import okio.ByteString
import okio.ByteString.Companion.toByteString
fun UByteArray.toIntArray(): IntArray =
map { it.toInt() }.toIntArray()
fun IntArray.toUByteArray(): UByteArray =
map { it.toUByte() }.toUByteArray()
fun UByteArray.toByteString(): ByteString =
toByteArray().toByteString()
fun UByteArray.decodeToString(): String =
toByteArray().decodeToString()
fun ByteString.toUByteArray(): UByteArray =
toByteArray().toUByteArray()
fun UByteArray.getPadded(length: Int): UByteArray {
val paddingLength = length - this.size
if (paddingLength < 0) {
throw Error("Length too small to hold parameter r")
}
val padding = UByteArray(paddingLength) { 0u }
return padding + this
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy