Varint

object Varint

Object Varint contains utility functions to encode and decode integers using variable-length quantity (Varint). Varint is a method of serializing integers using one or more bytes; smaller integers use fewer bytes. Used by Multicodec (which is used for DidKey)

Functions

Link copied to clipboard
fun decode(input: ByteArray): <Error class: unknown class><Int, Int>

Decodes the given ByteArray input from Varint format to a Pair of Integers. The function extracts the integer represented by the Varint and the number of bytes read to decode the integer.

Link copied to clipboard
fun encode(inp: Int): ByteArray

Encodes the given integer inp into a ByteArray using Varint encoding. The function supports encoding of Integers to Varint byte arrays, which are more efficient in representing smaller numbers using fewer bytes.