BASE85(1)

πŸ“¦ version 2.6.4, in nixos 26.05, nixpkgs unstable

πŸ’– BASE85(1) πŸ’–

okay so before we even start β€” real talk β€” this is the User Commands page for base85, bestie. it's giving "encoder decoder but make it cute" and i'm literally obsessed. and by the time you get to the bottom i'll hit you with the whole ARPA2.net / September 2024 sign-off, don't worry πŸŽ€


✨ NAME ✨

base85 β€” like, it encodes and decodes BASE85 representations of files. that's the whole job. that's the assignment. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

base85 [-e] [-p[p]] [-wnum] [-ofile]... [--] [file...]

base85 -d [-i] [-ofile]... [--] [file...]

base85 -de|-dx|-xe [-i] [-p[p]] [-wnum] [-ofile]... [--] [file...]

base85 -h

four whole moods, pick your fighter 🌈


🌸 DESCRIPTION 🌸

so base85 encodes data into BASE85 and decodes data from BASE85 representation. and when i say "encoding is default", i mean it β€” you literally don't have to ask for it. ✨ and yes, you can ask for both at once, and when you do, BASE85 will first be decoded and then re-encoded β€” like a little glow-up pass, for instance with other layout settings. 🫢

  • form one encodes into BASE85, which is, again, the default. the -p or -pp option and -wnum are the ones that influence the representation around the BASE85 characters. πŸŽ€
  • form two decodes from BASE85, with -i there to alter the input process.
  • form three decodes and then encodes, so it works like a recoder. the options are a mixture of the ones from the previous forms, where -x marks the non-BASE85 side for hexadecimal coding instead of the usual binary coding.
  • form four is just you asking for brief usage information. valid. love that for you. πŸ’€

also, options have long forms too, they're all listed down below, no gatekeeping here πŸ‘‘

the file... list is the input files with data to chew on. when they're absent, standard input gets read. and output is always sent to standard output. always. no cap. πŸ”₯


πŸ’œ OPTIONS πŸ’œ

the following options are available:

  • -e, --encode β€” ask for encoding into BASE85. when you combine it with -d, this triggers re-encoding. and when neither one is specified, -e is assumed. it's the default main character energy, honestly πŸ‘‘
  • -d, --decode β€” ask for decoding from BASE85. when combined with -e, this triggers re-encoding.
  • -x, --hex β€” use hexadecimal instead of binary input or output for the non-BASE85 side. the layout controls apply similar to what they do when formatting BASE85. 🧚
  • -ofile, --out file β€” send output to the file. this overrides the default behaviour of sending all output to standard output. 🚨 and listen, this is the important bit: this option must be used precisely as often as the number of input files. when no explicit input files are named at the end of the command line, standard input counts as a single input file to be matched with one -o option or none. so like, don't get cute with it. πŸ™ˆ
  • -p, --pretty β€” ask for pretty printing. this inserts a space after every block of 16 bytes. specify the option twice for an extra space after every chunk of 4 bytes, causing a double space between blocks. -pp bestie, it's a whole aesthetic ✨
  • -wnum, --wrap=num β€” wrap to the next line after num blocks of 16 bytes.
  • -i, --ignore-garbage β€” quietly drop any characters that are not in the BASE85 alphabet. πŸ—‘οΈ this option is not required to tolerate certain whitespace characters, namely space, horizontal tab, carriage return, line feed, form feed or \ \t\r\n\f. those ones it just vibes with already.
  • -h, -?, --help β€” show usage information with short options. 🫢

πŸ”₯ ALGORITHM πŸ”₯

okay this is the part where it gets good, sit down πŸ“

BASE85 is more compact than BASE64, and it aligns better with fixed-size binary data such as keys and hashes. where BASE64 aligns to multiples of 3 bytes, BASE85 aligns to multiples of 4 bytes β€” and the latter is common with such kinds of binary data. like, it's giving "built for this exact job" πŸ’…

but it is however possible to encode any number of bytes with BASE85, from zero up. the encoded size is 1.25 times the binary size, rounded up. not all encoded sizes translate to proper input, but there is no padding to trigger additional implementation problems β€” separation can be done with any other ASCII character, including spaces, tabs, line feeds, carriage return, form feed. no padding drama, we simply don't do that here 😌

the alphabet for this ARPA2 encoding in BASE85 is set to

#()*+,-./0..9:;<=>?@A..Z[]^_a..z{}~

which, in the order of the ASCII table, represent values 0..84. this set was chosen to have no commonly used escape or quote characters, so it should be usable in shells and in URLs. iconic honestly 🌈

groups of 5 BASE85 character values are raised to powers of 85, the most significant value first. when these are mapped to 4 bytes, it's done in network byte order (but it is just as possible to load it into a uint32_t for machine processing). 🧠

the BASE85 encoding of zero stands out clearly as a sequence of ##### characters. it is not true however that a binary sequence with all bits set stands out just as well as a sequence of ~~~~~ characters, because the highest value 85^5 lies a little over 2^32. a single byte 0xff for example, is represented in BASE85 as zz. πŸ’€ that's the trick, that's the whole trick.

groups shorter than 5 characters are considered to represent a prefix of the 4 bytes; 2 characters for 1 byte, 3 characters for 2 bytes and 4 characters for 3 bytes. and a single character? a single character does not contain sufficient information to form a byte. it's just out there. alone. πŸ™ˆ


πŸŽ€ AUTHOR πŸŽ€

written by Rick van Rein of OpenFortress.nl, for the ARPA2.net project. 🫢


😭 REPORTING BUGS 😭

for any discussion, including about bugs, please use the https://gitlab.com/arpa2/arpa2common/ project page for ARPA2 Common. we use its issue tracker to track bugs and feature requests. so like, bring your bugs, bring your feature requests, bring your whole group chat πŸ¦‹


copyright Β© 2024 Rick van Rein, ARPA2.net.

ARPA2 is funded from InternetWide.org, which in turn receives funding from various sources. part of this work was funded through a grant of SIDNfonds, a public interest fund geared towards a better Internet for all, and paid by administration fees for .nl domain names. other parts were funded by NLnet, a public interest fund geared towwards open source excellence, and by the NGI Pointer fund of the European Union. (yes, "towwards" β€” i'm not fixing the manpage's typo, i'm just lovingly pointing at it πŸ’€)


🌸 SEE ALSO 🌸

ARPA2 Common is documented on http://common.arpa2.net/ and its code is on https://gitlab.com/arpa2/arpa2common/ β€” go read it, iykyk πŸ‘‘


and that's the whole page bestie!! πŸŽ€ this was ARPA2.net, September 2024, BASE85(1) β€” go encode something pretty and wrap it at 16-byte blocks for me. mwah. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from