Base64 encode/decode data and print to standard output.
Syntax base64 [OPTION]... [FILE] Key -d --decode Decode data. -i --ignore-garbage When decoding, ignore non-alphabet characters. -w --wrap=COLS Wrap encoded lines after COLS character (default 76). Use 0 to disable line wrapping. --help Display this help and exit. --version Output version information and exit.
With no FILE, or when FILE is - , read from standard input.
Mandatory arguments to long options are mandatory for short options too.
Base64 is designed to carry data stored in binary formats across channels that only reliably support text. Base64 is particularly prevalent on the internet where its uses include the ability to embed image files or other binary assets inside textual assets such as HTML and CSS files.
For instance, background images and fonts can be specified in a CSS stylesheet file as data: URIs, instead of separate files.
<link rel="icon" href="data:image/png,base_64_string" type="image/png" />
The base64 encoded data is about 33% larger than the raw data.
The data are encoded as described for the base64 alphabet in RFC 4648.
This uses an alphabet of A-Z, a-z, 0-9, +/=
Padding at the end of the data is performed using the "=" character.
When decoding, the input may contain newlines in addition to the bytes of the formal base64 alphabet. Use --ignore-garbage to attempt to recover from any other non-alphabet bytes in the encoded stream.
base64 is often used to encode .PNG and .JPG data for use in HTML / CSS however data URIs can accept .SVG directly, encoding SVG in base64 will just make the file larger.
base64 is part of the coreutils (basic file, shell and text manipulation utilities) project.
Encode the text file sample.txt:
$ base64 sample.txt > encoded.txt
Encode a binary photo file:
$ base64 --wrap=0 favicon.ico > encoded.txt
Decode the file encoded.txt:
$ base64 encoded.txt > restore.txt
Encode a string:
$ echo abcdef | base64
"…the more things you know, or pretend to know, the more powerful you are. It doesn’t matter if things are true. What counts, remember, is to possess a secret." ~ Umberto Eco, (Foucault's Pendulum)
base32 - Base32 encode/decode data and print to standard output.
uuencode - Encode a binary file.
ASCII Table - (128 codes)