How to encode base64 via command line?

openssl can do this for you, and it's all installed with OS X by default; no need to install darwinports.

$ openssl base64 -in <infile> -out <outfile>

Without the -in option reads from stdin


Openssl can be used more succinctly:

echo -n 'input' | openssl base64

[ echo -n -> must be used, or encoding will be done including new line character ]

or

openssl base64 <ENTER> [type input] <CTRL+D>

Try using:

base64 -i <in-file> -o <outfile>

It should be available by default on OS X.