GolfScript, 8584 (81) bytes
~91,65,-.[{32+}/]5865>123,4897>58,-'+48>'+/'+++:B;.,~)3%:P{0+}*256base 64base{B=}/{;}P*'='P*]{13]n+}P*'='P*]76/"\r
":n*
The above will fit exactly 76 characters in a line, except for the last line. All lines are terminated by CRLF.
Note that RFC 2045 specifies a variable, maximumvariable, maximum line length of 76 characters, so at the cost of pretty output, we can save 3 additional bytes.
~91,65>123,97>58,48>'+/'+++:B;.,~)3%:P{0+}*256base 64base{B=}/{;}P*'='P*]{13]n+}/
This codeThe above will print one character per line, except for the last line, which can contain 0, 1 or 2 “=”=
chars. GolfScript will also append a final LF, which, according to RFC 2045, must be ignored by decoding software.
Example
$ echo '[99 97 102 195 169]' | golfscript base64.gs | cat -A
Y2Fmw6k=^M$
$ echo '[99 97 102 195 169]' | golfscript base64-sneaky.gs | cat -A
Y^M$
2^M$
F^M$
m^M$
w^M$
6^M$
k^M$
=^M$
$
How it works
~ # Interpret the input string.
91,65,-65> # Push the array corresponding to the string 'A...Z'.
.[{32+}/]123,97> # Push the array corresponding to the string 'a...z'.
58,48,-48> # Push the array corresponding to the string '0...9'.
'+/'+++:B; # Concatenate the three previous array with '+/' and save it in “B”.
.,~)3%:P # Calculate the number of bytes missing to yield a multiple of 3 and save in “P”.
{0+}* # Add that many zero bytes to the input array.
256base # Convert the input array into an integer.
64base # Convert that integer to base 64.
{B=}/ # For each digit, retrieve the corresponding character from “B”.
{;}P*'='P* # Replace the last “P” characters with a string containing that many “=” chars.
] ]76/ # Collect all charactersbytes on the stack into an array.
{13]n+}/ and split #into After76-byte eachchunks.
"\r\n":n* character, form# Join the stringchunks ofwith allseparator charactersCRLF plusand save CRLF as the new line terminator.