Stream encoder and decoder of base85 as used in e.g. Mercurial. Run with “-h" for synopsis. base85 reads from stdin and writes to stdout. Default operation is encoding, swithch to decoding with the “-d” flag.
Python's base85 API works on bytes-like objects. By chunking the input and output streams, base85 avoids having to keep the entire file in memory. The resulting streams are identical to encoding or decoding an entire file in one invokation, though, as the program would be quite useless otherwise.
Running the program with PyPy instead of CPython showed a large increase in throughput on my system, so the runtime invoked by the hashbang is pypy3. Changing it to python3 should obviously have no other effects than lower throughput on large files.
base85 does not prettyprint its output. forcedeol is a small utility which blindly enforces no more than 80 octets between each newline character. Compile with something like:
gcc -Wall -O2 -oforcedeol forcedeol.c