BinHex, originally short for "binary-to-
hexadecimal
Hexadecimal (also known as base-16 or simply hex) is a Numeral system#Positional systems in detail, positional numeral system that represents numbers using a radix (base) of sixteen. Unlike the decimal system representing numbers using ten symbo ...
", is a
binary-to-text encoding
A binary-to-text encoding is code, encoding of data (computing), data in plain text. More precisely, it is an encoding of binary data in a sequence of character (computing), printable characters. These encodings are necessary for transmission of ...
system which was used on the
classic Mac OS
Mac OS (originally System Software; retronym: Classic Mac OS) is the series of operating systems developed for the Mac (computer), Macintosh family of personal computers by Apple Computer, Inc. from 1984 to 2001, starting with System 1 and end ...
for sending binary files over
email
Electronic mail (usually shortened to email; alternatively hyphenated e-mail) is a method of transmitting and receiving Digital media, digital messages using electronics, electronic devices over a computer network. It was conceived in the ...
. BinHexed files take up more space than the original files, but avoid
data corruption
Data corruption refers to errors in computer data that occur during writing, reading, storage, transmission, or processing, which introduce unintended changes to the original data. Computer, transmission, and storage systems use a number of meas ...
by software that is not
8-bit clean.
History
TRS-80 BinHex
BinHex was originally written in 1981 by Tim Mann for the
TRS-80
The TRS-80 Micro Computer System (TRS-80, later renamed the Model I to distinguish it from successors) is a desktop microcomputer developed by American company Tandy Corporation and sold through their Radio Shack stores. Launched in 1977, it is ...
computer, as a standalone version of the encoding scheme of the popular
terminal emulator
A terminal emulator, or terminal application, is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term ''terminal'' covers all remote term ...
''ST80-III'', for users of other terminals. It was used for sending files via major
online services such as
CompuServe
CompuServe, Inc. (CompuServe Information Service, Inc., also known by its initialism CIS or later CSi) was an American Internet company that provided the first major commercial online service provider, online service. It opened in 1969 as a times ...
which, not being 8-bit clean, required files to use
ASCII armoring
A binary-to-text encoding is encoding of data in plain text. More precisely, it is an encoding of binary data in a sequence of printable characters. These encodings are necessary for transmission of data when the communication channel does not a ...
to survive. The system became very popular after Mann uploaded it to CompuServe's TRS-80 files area.
The original scheme converted the binary file contents to hexadecimal numbers, encoding those as
ASCII
ASCII ( ), an acronym for American Standard Code for Information Interchange, is a character encoding standard for representing a particular set of 95 (English language focused) printable character, printable and 33 control character, control c ...
digits and letters (
0
–
9
,
A
–
F
), and adding a
newline
A newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or ...
after every 60 characters. The system quickly gained the addition of a
checksum
A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify dat ...
at the end of every line to check for errors, and a subsequent conversion to use the
BASIC/S compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
allowed it to run much faster than the original
interpreted version.
BinHex files of the era were typically given the
file extension
File or filing may refer to:
Mechanical tools and processes
* File (tool), a tool used to remove fine amounts of material from a workpiece.
** Filing (metalworking), a material removal process in manufacturing
** Nail file, a tool used to gen ...
. Ports soon appeared for other popular computers of the era, including the
Apple II
Apple II ("apple Roman numerals, two", stylized as Apple ][) is a series of microcomputers manufactured by Apple Computer, Inc. from 1977 to 1993. The Apple II (original), original Apple II model, which gave the series its name, was designed ...
. When CompuServe later added support for 8-bit transfers, the format fell out of use.
Mac BinHex
When the Macintosh 128K was released in January 1984, the file upload problem still existed on CompuServe. In April, BinHex was ported to the Mac using MS BASIC for Macintosh. The Macintosh File System had introduced the storage of files as a "
resource fork
A resource fork is a fork of a file on Apple's classic Mac OS operating system that is used to store structured data. It is one of the two forks of a file, along with the data fork, which stores data that the operating system treats as unstruct ...
" and "data fork", and the Macintosh port only supported encoding of files' data fork, meaning it could only be used for data files. Several newer versions were published during 1984, resulting in BinHex 3 which could encode both forks.
Yves Lempereur, author of the first
assembler for the Mac, MacASM, ported BinHex 3 to assembly language, increasing its speed a hundred-fold, and released it as BinHex 1.0.
Compact BinHex
The simplicity of the original BinHex format made it inefficient, expanding every
byte
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
of input into two, as required by the hexadecimal representation, an 8-to-4 bit encoding. Lempereur implemented a new 8-to-6 bit encoding, which decreased file size by 50% and expanded the checksum from 8 to 16-bits, releasing this as BinHex 2.0.
The new encoding used the first 64 ASCII printing characters, including the space, to represent the data, similarly to
uuencoding. As the smaller files were incompatible with the older format, Lempereur changed the file extension to , with ''c'' meaning ''compact''. The name BinHex did not change, despite the format no longer being a hexadecimal representation.
BinHex 4 and 5
In 1985 Lempereur released BinHex 4.0, skipping 3.0 to avoid confusion with a similarly-numbered version of BASIC. This version performed the following sequence of operations:
* Generate
cyclic redundancy check
A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to digital data. Blocks of data entering these systems get a short ''check value'' attached, based on ...
s (CRCs) for the data fork, resource fork, and file metadata, instead of a single checksum
* Combine the forks and metadata with their checksums into a common 8-bit format
* Apply
run-length encoding
Run-length encoding (RLE) is a form of lossless data compression in which ''runs'' of data (consecutive occurrences of the same data value) are stored as a single occurrence of that data value and a count of its consecutive occurrences, rather th ...
to provide some compression
* Perform the 8-to-6 bit conversion.
The resulting files were roughly the same size as those from BinHex 2, but much more robust, with the
metadata
Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including:
* Descriptive ...
information in the header being protected from corruption by no longer being in plain text. The file extension for this new format was .
At about the same time, most online services had started to support robust 8-bit file transfer protocols such as
ZMODEM. This obviated the need for ASCII armoring, but on the Macintosh there was still the need to encode the two forks into one, leading to the development of the
MacBinary
MacBinary is a file format that combines the data fork and the resource fork of a classic Mac OS file into a single file, along with Hierarchical File System (Apple), HFS's extended metadata. The resulting file is suitable for transmission over Fil ...
file format. Lempereur released BinHex 5.0, which only differed by using MacBinary to combine the forks, but it saw little use.
Internet usage
While the
Internet
The Internet (or internet) is the Global network, global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a internetworking, network of networks ...
was gaining popularity in the 1990s, email was still the primary method of moving files. Relatively few people had full access, and services like
FTPmail were the only way many users could download files. Consequently, binary files still required encoding, and BinHex 4.0 remained a popular tool for doing so into the late 1990s. BinHexed files can still be found today in archives of
classic Mac OS
Mac OS (originally System Software; retronym: Classic Mac OS) is the series of operating systems developed for the Mac (computer), Macintosh family of personal computers by Apple Computer, Inc. from 1984 to 2001, starting with System 1 and end ...
software.
BinHex 4 file format
A BinHex file may begin with any text content, followed by a line which indicates the format of the file, and that binary data is about to begin: ''(This file must be converted with BinHex 4.0)''. The text preceding that line is ignored when the file is converted out of BinHex format.
The binary data is encoded to 7-bit ASCII characters, with three bytes of input (24 bits) divided into four 6-bit values, in a similar fashion to
Base64
In computer programming, Base64 is a group of binary-to-text encoding schemes that transforms binary data into a sequence of printable characters, limited to a set of 64 unique characters. More specifically, the source binary data is taken 6 bits ...
encoding but using a different set of characters.
The encoded data has a colon () placed before and after it, and is split into lines of a maximum of 64 characters in length.
Example of a BinHex-encoded file
References
Citations
*
*
*
* {{cite web, first=Tim, last=Mann, title=Prehistory of BinHex, url=https://www.tim-mann.org/binhex.html, year=1997
See also
*
Binary-to-text encoding
A binary-to-text encoding is code, encoding of data (computing), data in plain text. More precisely, it is an encoding of binary data in a sequence of character (computing), printable characters. These encodings are necessary for transmission of ...
for a comparison of various encoding algorithms
External links
BinHex 4.0at Macintosh Repository
Archive formats
Binary-to-text encoding formats
Computer-related introductions in 1984