This page describes, in Unix manual page style, a program available for downloading from this site which encodes binary files in the “Base64” format used by MIME-encoded documents such as electronic mail messages with embedded images and audio files.
base64 - encode and decode base64 files
base64 [ -d / -e ] [ options ] [ infile ] [ outfile ]
The MIME (Multipurpose Internet Mail Extensions) specification (RFC 1341 and successors) defines a mechanism for encoding arbitrary binary information for transmission by electronic mail. Triplets of 8-bit octets are encoded as groups of four characters, each representing 6 bits of the source 24 bits. Only characters present in all variants of ASCII and EBCDIC are used, avoiding incompatibilities in other forms of encoding such as uuencode/uudecode.
base64 is a command line utility which encodes and decodes files in this format. It can be used within a pipeline as an encoding or decoding filter, and is most commonly used in this manner as part of an automated mail processing system.
base64 returns status 0 if processing was completed without errors, 1 if an I/O error occurred or errors were detected in decoding a file which indicate it is incorrect or incomplete, and 2 if processing could not be performed at all due, for example, to a nonexistent input file.
If no infile is specified or infile is a single “-”, base64 reads from standard input; if no outfile is given, or outfile is a single “-”, output is sent to standard output. The input and output are processed strictly serially; consequently base64 may be used in pipelines.
Little or no error checking is done when decoding, other than validating that the input consists of a multiple of four characters in the encoding set. This is inherent in the design of base64, which assumes transmission integrity is the responsibility of a higher-level protocol.
The archive contains source code for the utility, a Makefile for Unix systems, and a ready-to-run executable for 32-bit Windows platforms. Windows users may also download base64.zip, a ZIPped archive containing the Windows executable.
Christian Ferrari contributed code which permits the base64 utility to work on EBCDIC based systems such as UNIX Services for OS/390 2.7 (ESA/390).
This software is in the public domain. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided “as is” without express or implied warranty.