kencode

Top-level

Types

Link copied to clipboard
interface Alphabet

Maps indices to characters (encoding) and characters back to indices (decoding). indexOf returns -1 for characters not in the alphabet.

Link copied to clipboard
object Base36 : BaseRadix

Base36 encoder/decoder using digits and lowercase characters.

Link copied to clipboard
object Base62 : BaseRadix

Base62 encoder/decoder using digits, lowercase, then uppercase characters.

Link copied to clipboard
open class Base64(val alphabet: CharArray) : ByteEncoding

RFC 4648–compatible Base64 encoder/decoder.

Link copied to clipboard
object Base64Url : Base64

URL- and filename-safe variant of Base64 using the BASE_64_URL alphabet.

Link copied to clipboard
open class Base85(alphabet: CharArray) : ByteEncoding

Generic Base85 encoder/decoder supporting both ASCII85 and ZeroMQ Z85. 4 input bytes -> 5 output chars. Allows final partial group (1–3 bytes -> 2–4 chars).

Link copied to clipboard
open class BaseRadix(alphabet: Alphabet, val blockSize: Int = 32) : ByteEncoding

Generic base-N encoder/decoder for binary data using arbitrary alphabets and block processing.

Link copied to clipboard
interface ByteEncoding

Abstraction for bidirectional byte–text encodings (e.g., Base62, Base64).

Link copied to clipboard
class CharAlphabet(chars: String) : Alphabet

Alphabet backed by an explicit string of characters.

Link copied to clipboard
interface Checksum

Generic checksum interface that produces a fixed number of bytes.

Link copied to clipboard

Strips leading zero bytes before encoding and restores them on decode.

Link copied to clipboard
open class Crc16(poly: Int = 4129, init: Int = 65535, refin: Boolean = true, refout: Boolean = true, xorOut: Int = 65535) : Checksum

CRC-16/X-25 implementation.

Link copied to clipboard
open class Crc32(poly: Int = 79764919, init: Int = 0xFFFFFFFF.toInt(), refin: Boolean = true, refout: Boolean = true, xorOut: Int = 0xFFFFFFFF.toInt()) : Checksum

CRC-32/ISO-HDLC implementation.

Link copied to clipboard
open class Crc8(poly: Int = 7, init: Int = 0, refin: Boolean = false, refout: Boolean = false, xorOut: Int = 0) : Checksum

CRC-8/SMBUS implementation.

Link copied to clipboard
data class EncodedConfiguration(val codec: ByteEncoding = Base62, val transform: PayloadTransform? = null, val binaryFormat: BinaryFormat = PackedFormat.Default)

Holds the configuration for an EncodedFormat instance.

Link copied to clipboard
open class EncodedFormat(val configuration: EncodedConfiguration) : StringFormat

Text StringFormat that produces short, predictable string tokens by composing:

Link copied to clipboard

Builder for configuring EncodedFormat instances.

Link copied to clipboard

Integer encoding strategy for Int and Long fields in PackedFormat.

Link copied to clipboard
data class PackedConfiguration(val defaultEncoding: IntPacking = IntPacking.DEFAULT)

Holds the configuration for a PackedFormat instance.

Link copied to clipboard
class PackedDecoder : Decoder, CompositeDecoder

Binary decoder for the PackedFormat wire format. Reads merged class bitmask headers and per-field data produced by PackedEncoder.

Link copied to clipboard
class PackedEncoder : Encoder, CompositeEncoder

Binary encoder for the PackedFormat wire format. Accumulates merged class bitmask headers and per-field data, producing output consumable by PackedDecoder.

Link copied to clipboard
open class PackedFormat(val configuration: PackedConfiguration = PackedConfiguration(), val serializersModule: SerializersModule = EmptySerializersModule()) : BinaryFormat

Compact BinaryFormat optimized for small, flat Kotlin data classes.

Link copied to clipboard

Builder for configuring PackedFormat instances.

Link copied to clipboard
@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class PackedType(val type: IntPacking)

Overrides the integer encoding strategy for an Int or Long field in PackedFormat. Falls back to kotlinx.serialization.protobuf.ProtoType if present, then PackedConfiguration.defaultEncoding.

Link copied to clipboard

Transforms a binary payload before base-encoding and after base-decoding.

Link copied to clipboard
class UnicodeRangeAlphabet(start: Int = 32, val size: Int = 0xD800 - 0x0020) : Alphabet

Alphabet backed by a contiguous Unicode range starting at start. Defaults to U+0020 – U+D7FF (55,264 characters), the largest BMP range that avoids surrogate code points.

Properties

Link copied to clipboard
const val ASCII85: String

Standard ASCII85 alphabet (printable ASCII ! through u).

Link copied to clipboard
const val BASE_62: String

Base62 alphabet: digits, lowercase letters, then uppercase letters.

Link copied to clipboard
const val BASE_64: String

Standard RFC 4648 Base64 alphabet (uses + and /).

Link copied to clipboard
const val BASE_64_URL: String

URL- and filename-safe Base64 alphabet from RFC 4648 §5 (uses - and _).

Functions

Link copied to clipboard

Wraps this Checksum as a PayloadTransform that appends the digest on encode and strips and verifies it on decode.

Link copied to clipboard
fun EncodedFormat(from: EncodedFormat = EncodedFormat.Default, builderAction: EncodedFormatBuilder.() -> Unit): EncodedFormat

Creates a customized EncodedFormat instance.

Link copied to clipboard
fun PackedFormat(from: PackedFormat = PackedFormat.Default, builderAction: PackedFormatBuilder.() -> Unit): PackedFormat

Creates a customized PackedFormat instance.

Link copied to clipboard

Chains two transforms into a pipeline.