@eryx/encoding/base85 Module

JSON

Z85 (ZeroMQ Base85) encoding utilities.

Encodes and decodes binary buffer data using the Z85 alphabet, a compact base-85 representation designed for use in source code and XML. Input length must be a multiple of 4 bytes.

local base85 = require("@eryx/encoding/base85")
local data = buffer.fromstring("\x86\x4f\xd2\x6f")
print(base85.encode(data)) -- "HelloWorld" (example)

Caution

Z85 requires the input buffer length to be a multiple of 4 bytes for encoding and the string length to be a multiple of 5 characters for decoding. Inputs that don’t meet this constraint will raise an error.

Summary

Functions

base85.encode(buf: buffer)string
base85.decode(str: string)buffer

API Reference

Functions

base85.encode

Encodes a buffer into a Z85 string.

The buffer length must be a multiple of 4.

base85.encode(buf: buffer)string

Parameters

buf: buffer

The binary data to encode.

Returns

string

The Z85-encoded string.

base85.decode

Decodes a Z85 string back into a buffer.

The string length must be a multiple of 5.

base85.decode(str: string)buffer

Parameters

str: string

The Z85-encoded string.

Returns

buffer

The decoded binary data.