Is there a terminal command in Mac OS X which will base64 encode a file or stdin?
|
Without the |
|||||||
|
|
In terms of speed, I would use openssl followed by perl, followed by uuencode. In terms of portability, I would use uuencode followed by Perl followed by openssl (If you care about reusing the code on as many other UNIX like stock platforms as possible). Be careful though because not all UNIX variants support the -m switch (iirc AIX does, HP/UX does, Solaris doesn't).
Use the -m switch to uuencode file_in.txt per base64 as specified by RFC1521 and write it to filename.b64 (with filename_when_uudecoded.txt as the default filename when decoded):
STDIN example:
|
|||
|
|
|
Openssl can be used more succinctly:
or
|
|||
|
|
There is Perl plus MIME::Base64:
This comes pre-installed. You can specify separate files on the command line (or supply the data on standard input); each file is separately encoded. You can also do:
This backs up file1 to file1.txt, and writes the Base-64 encoded output over the original file. |
|||
|
|
Where name is the name to display in the encoded header. Example:
or
|
||||
|
|
|
Let me expand on Steve Folly's answer:
Just an easier-to-use representation. |
|||
|
|
|
recode should do the trick for you
Here is the darwinports page for recode if its not already available. |
|||||
|
|

base64 -dorbase64 -Ddepending on your operating system. OSX uses-D. – Chris Johnson Nov 30 '12 at 22:06