# Base85

Under the name Base85 , different, mutually incompatible coding methods are summarized, which convert 8-bit binary data into a sequence of printable ASCII characters. They have in common that they encode blocks of four bytes each in five ASCII characters. This requires at least 85 different characters, which is what gave this process its name. The advantage is the slightly lower coding overhead of 25% compared to 33% that occurs with standardized Base64 coding.

This encoding is most widespread in the PostScript file format from Adobe , this encoding version is also known as Ascii85 .

## Basic idea

Four bytes can assume 256 4 = 4,294,967,296 different possible states. In order to encode these with the least possible overhead , a suitable subset of the printable ASCII characters is selected, which makes it possible to get by with 5 characters. An alphabet of at least 85 characters is required for this, as 85 5 = 4,437,053,125 ≥ 4,294,967,296. (84 characters are not enough, because 84 5 = 4,182,119,424 <4,294,967,296).

If the four bytes are labeled with and and the five coded characters , the following conversion formula results: ${\ displaystyle b_ {1}, b_ {2}, b_ {3}}$ ${\ displaystyle b_ {4}}$ ${\ displaystyle c_ {1}, ..., c_ {5}}$ ${\ displaystyle (b_ {1} \ cdot 256 ^ {3}) + (b_ {2} \ cdot 256 ^ {2}) + (b_ {3} \ cdot 256) + b_ {4} = (c_ {1 } \ cdot 85 ^ {4}) + (c_ {2} \ cdot 85 ^ {3}) + (c_ {3} \ cdot 85 ^ {2}) + (c_ {4} \ cdot 85) + c_ { 5}}$ In other words: The four bytes are interpreted as a four-digit number on the base 256 and converted into a five-digit number on the base 85.

The codes are now represented by certain printable ASCII characters. ${\ displaystyle c_ {1} ... c_ {5}}$ ## PostScript

The Base85 coding in PostScript adds the value 33 to the values and thus uses the ASCII values ​​33 to 117, which correspond to the ASCII characters to . The only exception: four consecutive zero bytes are not encoded with, but with a single one . This simple type of data compression reduces or even compensates for the coding overhead of Base85, depending on the data content, especially since longer sequences of zero bytes can occur quite frequently, especially with raster graphics embedded in PostScript. When encoding, spaces and line breaks can be inserted as desired, for example to achieve a certain maximum line length. These characters are ignored during decoding. All other characters represent an error, whereupon the decoding stops. ${\ displaystyle c_ {1} ... c_ {5}}$ !u!!!!!z

## IPv6 address coding according to RFC 1924

A slightly different coding was proposed in RFC 1924 for IPv6 addresses (note the date of publication of this RFC ). The 128-bit IPv6 address to be encoded is not divided into four blocks of 32 bits each, but rather as a 128-bit number. This is successively divided by 85, the residues occurring are the "digits" of the Base85 coding.

Each IPv6 address can be coded in 20 numbers from the range 0… 84. These numbers are assigned to ASCII characters using a look-up table, as the aim was to avoid certain ASCII characters during the encoding, which “could be problematic in certain environments”. The look-up table used is as follows:

## Other uses

Despite the slightly lower overhead, the Base85 coding - except in special areas - could not establish itself. An even more efficient process now exists with Base91. For the ASCII coding of binary data in e-mails and Usenet articles, only Base64 coding according to the MIME standard is intended.