Expand/Shrink

base64

The file builtins\base64.e (an autoinclude) provides support for converting data to and from base64, which is safe to transmit over the internet.

Base64 is used to encode binary data into an ASCII string; this allows binary data to be transmitted using media designed to transmit text data only.
See http://en.wikipedia.org/wiki/Base64 and the RFC 2045 standard for more information.

You can think of base64 as similar to hexadecimal, except that it packs 6 bits of information into every byte rather than 4.
Obviously, for comparison with the 6 and 4, the raw data contains a full 8 bits of information in every byte.
Ignoring padding (at most 3 bytes) and line breaks (2 bytes between every 76), an encoded string is 33.33% larger than the raw data, and the decoded data is 75% of the size of the base64-encoded string.

These routines are fully supported by pwa/p2js.

encode_base64 Convert data to a base64 encoded string.
decode_base64 Convert a base64 encoded string back to the original data.