Encode or Decode a binary file.
Syntax base64 [-h | -D | -d] [-b count] [-i input_file] [-o output_file] Key: -b count --break=count Insert line breaks every count characters. The default is 0, which generates an unbroken stream. -d -D --decode Decode incoming Base64 stream into binary data. -h --help Print usage summary and exit. -i input_file --input=input_file Read input from input_file. The default is stdin; passing "-" also represents stdin. -o output_file --output=output_file Write output to output_file. The default is stdout; passing "-" also represents stdout. -w column Wrap encoded output after column.
The base64 utility acts as a base64 decoder when passed the --decode (or -d) flag and as a base64 encoder otherwise.
As a decoder it only accepts raw base64 input and as an encoder it does not produce the framing lines. base64 reads standard input or file if it is provided and writes to standard output.
Options --wrap (or -w) and --ignore-garbage (or -i) are accepted for compatibility with GNU base64, but the latter is unimplemented and silently ignored.
Encode the file input.txt:
$ base64 -i input.txt -o output.txt
Encode a string on the command line:
$ echo the price is right | base64
dGhlIHByaWNlIGlzIHJpZ2h0Cg==
Decode a string on the command line:
$ echo dGhlIHByaWNlIGlzIHJpZ2h0Cg== | base64 -d
"Everything Not Saved Will Be Lost" ~ T. Michael Martin
Local man page: base64 - Command line help page on your local machine.
uuencode - Encode a binary file.
uudecode - Decode a binary file.
basename - return filename or directory portion of pathname.
gzip - Compress or decompress files.
uucp - Unix to Unix copy.