BinHex, originally short for "binary-to-hexadecimal", is a binary-to-text encoding system that was used on the classic Mac OS for sending binary files through e-mail. Originally a hexadecimal encoding, subsequent versions of BinHex are more similar to uuencode, but combined both "forks" of the Mac file system together along with extended file information. BinHexed files take up more space than the original files, but will not be corrupted by non-"8-bit clean" software.
BinHex was originally written in 1981 by Tim Mann for the TRS-80, as a stand-alone version of an encoding scheme originally built into a popular terminal emulator, ST80-III by Lance Micklus. BinHex was used for sending files via major online services such as CompuServe, which were not "8-bit clean" and required ASCII armoring to survive. Not everyone used ST-80, however, so Mann wrote BinHex to allow users of other emulators to use the format.
The original ST-80 system worked by converting the binary file contents to hexadecimal numbers, which were themselves encoded as ASCII digits and letters. It then added a newline after every 60 characters. The system became very popular after Mann uploaded it to CompuServe's TRS-80 files area. The system quickly gained the addition of a checksum at the end of every line to check for errors. Bill Stockwell converted that version to the BASIC/S compiler, which ran much faster than Mann's interpreted version.
BinHex files of the era were typically given the . Ports soon appeared for other popular platforms of the era, including the Apple II. CompuServe later added support for 8-bit transfers, and the format quickly disappeared.
The file upload problem still existed on CompuServe when the Mac was first released in 1984. In April 1984, William Davis ported BinHex to the Mac using Microsoft BASIC to produce a version that was largely identical to the TRS-80 versions of the same era. This version only supported encoding of the "data fork", ignoring the resource fork, which meant it could only be used for data files.