0

Decoded

Ascii85

Encoded

Ascii85
Variant

About Ascii85

Ascii85 is an encoding scheme that uses 7-bit printable ASCII characters, also known as Base85.

Ascii85 divides the data into 4 bytes each and converts them into 5 ASCII characters to represent them.

There are many variants of Ascii85, and DenCode supports the following three types of Ascii85. The original being btoa, followed by Adobe and Z85.

Summary
Z85Used by ZeroMQ." \" (backslash) and "'" (apostrophe) characters that require escaping are not used.
AdobeIt is used to encode images and other data in Adobe's PostScript and PDF (Portable Document Format) files. It is enclosed in "<~" and "~>".
btoaA form of the UNIX btoa command. It was used in the past for exchanging binary data, but is no longer common. Enclosed in "xbtoa Begin" and "xbtoa End" lines.

The ASCII characters used in Ascii85 are as follows: treat the 4-byte value as a big-endian unsigned integer, calculate each digit (5 digits) of the 85 decimal system from it, and then find the Ascii85 conversion result based on the following ASCII characters

ASCII characters
Z850123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#
Adobe!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu
btoa!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu
(The original was from " " (space) to "t", but because some mailers excluded trailing spaces, it was later replaced by the "!" to "u" characters without spaces.)

For example, if we convert "Hello" with Ascii85, it will look like this.

1. Separate every 4 bytes; if less than 4 bytes, end with "00" for padding.

48656C6C(16) 6F000000(16)  (Hell o)

2. Every 4 bytes are treated as a big-endian unsigned integer, and the value is converted to each digit of the 85 decimal system.

48656C6C(16)
= 1214606444(10)
= 23 * 854 + 22 * 853 + 66 * 852 + 52 * 85 + 49
6F000000(16)
= 1862270976(10)
= 35 * 854 + 57 * 853 + 33 * 852 + 65 * 85 + 26

3. Convert each digit of the 85 decimal system to an ASCII character. If the end is padded with "00", the padding is excluded in the case of Adobe/Z85.

23226652493557336526
Z85nm=QNzV
Adobe87cURDZ
btoa87cURDZBb;

4. The characters are all joined together to form the Ascii85 conversion result. adobe is enclosed in "<~" & "~>", with a new line every 80 characters. btoa is enclosed in "xbtoa Begin" & "xbtoa End" (including data length, checksum, etc.), with a new line every 78 characters.

Conversion result
Z85nm=QNzV
Adobe<~87cURDZ~>
btoaxbtoa Begin
87cURDZBb;
xbtoa End N 5 5 E 42 S 1f9 R a9f

Several other contractions have been defined.

Contractions
Z85None
Adobe00000000(16) -> z
btoa00000000(16) -> z
20202020(16) -> y (btoa v4.2 or later)