Python 3.4+base64function
base64.b85encode()
Ascii85 and Base85
Encodes bytes as Base85 with the alphabet used in git patches. The alphabet differs from Ascii85, though the density is the same.
Syntax
base64.b85encode(b, pad=False)
b85 and a85 are incompatible: the same bytes give different strings (b'hello' → b'Xk~0{Zv' versus b'BOu!rDZ'), and one cannot be read with the other. pad=True pads the input with zeros to a multiple of 4, and decoding returns those zeros as part of the data, so the original length has to be stored separately.
Examples
import base64
print(base64.b85encode(b'hello'), base64.a85encode(b'hello')) # → b'Xk~0{Zv' b'BOu!rDZ'
print(base64.b85decode(base64.b85encode(b'hi', pad=True))) # → b'hi\x00\x00' — нули остались
See also
Open in the full glossarydocs.python.orgReport an inaccuracy