What's a portable way to base64 encode something?

Wait 5 sec.

I just learned today that there is no guarantee that the base64 binary will be available on every system, and I need to encode a string. I have since found a project that claims to be portable: https://raw.githubusercontent.com/ko1nksm-shlab/sh-base64/refs/heads/main/base64.sh. Turns out this isn't portable either since it uses fold, which does not exist on Busybox systems. I have since found another implementation in awk here: http://www.turtle.dds.nl/b64enc.awk This assumes the input is ascii only, and I need ASCII + \0 character. I'm still in search of a solution and not having much luck, but I think this should already exist somewhere. Anyone have any ideas?   submitted by   /u/kudikarasavasa [link]   [comments]