base64 decoding

macosxhints – Use OpenSSL for Base64 encode and decode

With reference to the Archive attachments from Mail.app messages hint, we can use OpenSSL to convert a specific Mail attachment from Base64 and back using the following command(s):

To decode from Base64:

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

Conversely, to encode to Base64:

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

Where infile refers to the input filename (source) and outfile refers to the output filename (destination). Refer to man enc for more detailed information on using OpenSSL commands.

  1. You forgot to HTML-entity encode the angle brackets. Your infile and outfiles are missing from this description!

  2. Fixed – thanks for pointing that out

    8)

  3. I have this other note to myself as well…

    base64 decoding
    perl -pe 'use MIME::Base64; $_=MIME::Base64::encode($_);'
    perl -pe 'use MIME::Base64; $_=MIME::Base64::decode($_);'

  4. You can also use base64 from Mac Ports. Install mac ports.

    Search for the base64 binary:

    > port search base64

    base64 mail/base64 1.3 Encode and decode base64 files

    and then install it:

    > sudo port install base64