Often I find myself in the need to base64 encode a file. Typically an image to inline in a CSS file. I added the following to my ~/.bash_profile
(OSX) for convenience:
function base64() {
openssl base64 < $1 | tr -d '\n' | pbcopy
}
Now I simply run base64 <filename>
from the terminal to get the base64 encoded file in the clipboard for easy pasting into wherever I want to.