Base16

Base16 (aka "hex") encoding/decoding in accordance with RFC 4648 section 8.

e.g.

val base16 = Base16.Builder {
    isLenient(enable = true)
    lineBreak(interval = 64)
    lineBreakReset(onFlush = true)
    encodeLowercase(enable = true)
    backFillBuffers(enable = true)
}

val text = "Hello World!"
val bytes = text.encodeToByteArray()
val encoded = bytes.encodeToString(base16)
println(encoded) // 48656c6c6f20576f726c6421

// Alternatively, use the static implementation containing
// pre-configured settings, instead of creating your own.
val decoded = encoded.decodeToByteArray(Base16).decodeToString()
assertEquals(text, decoded)

See also

Types

Link copied to clipboard
class Builder

A Builder

Link copied to clipboard

A static instance of EncoderDecoder configured with a Base16.Builder.lineBreak interval of 64, and remaining Base16.Builder DEFAULT values.

Link copied to clipboard

Holder of a configuration for the Base16 encoder/decoder instance.

Functions

Link copied to clipboard
protected override fun name(): String
Link copied to clipboard
Link copied to clipboard