1001Ferramentas
📡Converters

Z85 Encoder/Decoder (ZeroMQ)

Encode and decode data in Z85, the ZeroMQ flavor of Base85 that uses an alphabet safe for strings and configuration files.

Z85

Z85: the base85 ZeroMQ picked

Z85 encodes four bytes into five characters, like any base85, but with a hand-picked alphabet: it avoids the single quote, the double quote, the backslash and the backtick. The reason is practical — the resulting text can be pasted inside a string literal in practically any language, into a configuration file and onto a command line without needing escapes.

Type the text and get the encoding. One restriction comes from the specification: the byte length must be a multiple of four. Unlike Ascii85, Z85 defines no padding for an incomplete final group, and the page refuses rather than inventing one. Anyone encoding arbitrary lengths has to agree padding out of band, together with whatever will decode it.

Its best-known use is CurveZMQ, ZeroMQ's security mechanism, where 32-byte keys become 40 characters — a multiple of four by construction, which explains why the limitation never bothered anyone in its home context. The implementation was checked against the specification vector: bytes 86 4F D2 6F B5 59 F7 5B encode exactly to HelloWorld.

Frequently asked questions

Why must the length be a multiple of four?
Because the Z85 specification simply does not define what to do with an incomplete group. Ascii85 and base64 define padding; Z85 was designed for data of known fixed size, such as keys, and went without. Padding on your own only works if the decoder knows the same convention.
How does it differ from Ascii85?
The arithmetic is the same; the alphabet is different. Ascii85 uses a contiguous run of characters starting at the exclamation mark, which includes quotes and the backslash — precisely the ones that get in the way inside code. Z85 chose 85 symbols avoiding those, at the cost of a non-contiguous alphabet.
Does it work for arbitrary binary data?
It does, as long as the length is a multiple of four. The gain over base64 is size — 25% growth against 33% — and over Ascii85 it is convenience when embedding in code. For data going into a URL, none of the three is ideal: base64url remains the choice.

Related Tools