BinHex
Encyclopedia
BinHex, short for "binary-to-hexadecimal", is a binary-to-text encoding system that was used on the Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

 for sending binary files through e-mail
E-mail
Electronic mail, commonly known as email or e-mail, is a method of exchanging digital messages from an author to one or more recipients. Modern email operates across the Internet or other computer networks. Some early email systems required that the author and the recipient both be online at the...

. It is similar to Uuencode
Uuencode
Uuencoding is a form of binary-to-text encoding that originated in the Unix program uuencode, for encoding binary data for transmission over the uucp mail system.The name "uuencoding" is derived from "Unix-to-Unix encoding"...

, but combined both "forks"
Resource fork
The resource fork is a construct of the Mac OS operating system used to store structured data in a file, alongside unstructured data stored within the data fork. A resource fork stores information in a specific form, such as icons, the shapes of windows, definitions of menus and their contents, and...

 of the Mac file system together, along with extended file information. BinHexed files take up more space than the original files, but are far less likely to be corrupted
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...

 in transit.

History

BinHex was originally written by Tim Mann for the TRS-80
TRS-80
TRS-80 was Tandy Corporation's desktop microcomputer model line, sold through Tandy's Radio Shack stores in the late 1970s and early 1980s. The first units, ordered unseen, were delivered in November 1977, and rolled out to the stores the third week of December. The line won popularity with...

, as a stand-alone version of an encoding scheme originally built into a popular terminal emulator
Terminal emulator
A terminal emulator, terminal application, term, or tty for short, is a program that emulates a video terminal within some other display architecture....

. It worked by converting the binary file contents to hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

 numbers, which were themselves encoded as ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 digits and letters. BinHex files of the era were typically given the file extension .hex. BinHex was used for sending files via major online services such as CompuServe
CompuServe
CompuServe was the first major commercial online service in the United States. It dominated the field during the 1980s and remained a major player through the mid-1990s, when it was sidelined by the rise of services such as AOL with monthly subscriptions rather than hourly rates...

, which were not "8-bit clean
8-bit clean
8-bit clean describes a computer system that correctly handles 8-bit character sets, such as the ISO 8859 series and the UTF-8 encoding of Unicode.- History :...

" and required ASCII armoring to survive. CompuServe
CompuServe
CompuServe was the first major commercial online service in the United States. It dominated the field during the 1980s and remained a major player through the mid-1990s, when it was sidelined by the rise of services such as AOL with monthly subscriptions rather than hourly rates...

 later addressed this problem in the mid-1980s with the addition of 8-bit clean file transfer protocols, and solutions like BinHex stopped being used.

The file upload problem still existed on CompuServe when the Mac was first released in 1984. William Davis ported BinHex to the Mac using Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 BASIC in a simple version that could encode the data fork only, ignoring the resource fork
Resource fork
The resource fork is a construct of the Mac OS operating system used to store structured data in a file, alongside unstructured data stored within the data fork. A resource fork stores information in a specific form, such as icons, the shapes of windows, definitions of menus and their contents, and...

. The rise in use of Internet
Internet
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite to serve billions of users worldwide...

 e-mail coincided roughly with the release of the Macintosh, and Davis's version was posted on the Info-Mac
Info-Mac
Info-Mac is an online community, news aggregator and shareware file hosting service covering Apple Inc. products, including the iPhone, iPod and especially the Macintosh. Established in 1984 as an electronic mailing list, Info-Mac is notable as being the first online community for Apple's then-new...

 mailing list
Mailing list
A mailing list is a collection of names and addresses used by an individual or an organization to send material to multiple recipients. The term is often extended to include the people subscribed to such a list, so the group of subscribers is referred to as "the mailing list", or simply "the...

 by Joel Heller in June 1984. Several newer versions were published during 1984, resulting in BinHex 3 that could encode both forks.

Yves Lempereur, author of the first assembler for the Mac, MacASM, found that in order to upload his files to CompuServe he had to use BinHex. The BASIC version was very slow, so he ported it to assembler and released it as BinHex 1.0. The program was roughly a hundred times as fast as the BASIC version, and soon upgrade requests were flooding in.

The original BinHex was a fairly simple format, one that was not very efficient because it expanded every byte of input into two, as required by the hexadecimal representation—an 8-to-4 bit encoding. For BinHex 2.0, Lempereur used a new 8-to-6 encoding that improved file size by 50% and took the opportunity to add a new CRC
Cyclic redundancy check
A cyclic redundancy check is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data...

 error checking routine in place of the earlier checksum
Checksum
A checksum or hash sum is a fixed-size datum computed from an arbitrary block of digital data for the purpose of detecting accidental errors that may have been introduced during its transmission or storage. The integrity of the data can be checked at any later time by recomputing the checksum and...

. Even though the new encoding was no longer hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

 in nature, the established name of the program was retained. The smaller files were incompatible with the older ones, so the extension became .hcx, c for compact. Unfortunately, the compact format also had its problems. The 6-bit encoding produced a number of characters that some foreign-language mail programs would convert into local versions, thereby destroying the file. In addition, the file metadata
Metadata
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...

 information was still placed in the file in plain text, and therefore could become corrupted in the same fashion.

In order to solve all of these problems, Lempereur released BinHex 4.0 in 1985, skipping 3.0 to avoid confusion with the now long-dead BASIC version. 4.0 carefully selected its character mappings to avoid ones that were translated by mail software, encoded all the information including the file information and protected everything with multiple CRCs. The resulting .hqx files were roughly the same size of the .hcx's, but much more robust.

At about the time BinHex 4 was released, most online services started supporting robust 8-bit file transfer protocols such as Zmodem
ZMODEM
ZMODEM is a file transfer protocol developed by Chuck Forsberg in 1986, in a project funded by Telenet in order to improve file transfers on their X.25 network...

, and the need for ASCII armoring went away. This left a problem on the Mac however, as there was still the need to encode the two forks into one. A team effort among Macintosh communications programmers resulted in MacBinary
MacBinary
Due to the metadata-rich nature of the Macintosh Hierarchical File System, transferring Mac OS files to platforms that do not support HFS can be problematic. MacBinary was developed as a means of preserving this structure without sacrificing portability. It combines the data and resource forks...

, which left the contents of the forks in their original 8-bit format and added a simple header for combining them on reception. MacBinary files were thus much smaller than BinHex. Lempereur released BinHex 5.0, almost identical to 4.0 with the exception that it used MacBinary to combine the forks before running the 8-to-6 encoding, but it saw little use, as he expected.

However, on the Internet
Internet
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite to serve billions of users worldwide...

, e-mail was still the primary method of moving files. At the time only a few people had access to the Internet, and it was an isolated community unto its own. Years later when he first got onto the Internet, Lempereur was surprised to find that BinHex 4.0 was still extremely popular. The same ends could be achieved by first using MacBinary
MacBinary
Due to the metadata-rich nature of the Macintosh Hierarchical File System, transferring Mac OS files to platforms that do not support HFS can be problematic. MacBinary was developed as a means of preserving this structure without sacrificing portability. It combines the data and resource forks...

 or AppleSingle
AppleSingle
AppleSingle Format and AppleDouble Format are file formats developed by Apple Computer to store Mac OS "dual-forked" files on the Unix filesystem being used in A/UX, Apple's first Unix-like operating system. AppleSingle combined both file forks and the related Finder meta-file information into a...

 to combine the forks, and then using Uuencode
Uuencode
Uuencoding is a form of binary-to-text encoding that originated in the Unix program uuencode, for encoding binary data for transmission over the uucp mail system.The name "uuencoding" is derived from "Unix-to-Unix encoding"...

 or Base64
Base64
Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation...

 on the resulting file, but none of these solutions ever became popular and BinHex 4.0 survived well into the late 1990s. Various file archives of pre-Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 software are still filled with BinHexed files.

Format

Looking at the contents of a BinHex file, one will notice that it has a message on the first line identifying it as BinHex, followed by many 64-character lines made up of seemingly random letters, numbers, and punctuation marks. Here is a sample of what BinHex actually looks like:


(This file must be converted with BinHex 4.0)
$f*TEQKPH#jdCA0d,R0TG!"6594%8dP8)3#3"!&m!*!%EMa6593K!!%!!!&mFNa

KG3,r!*!$&[rr$3d,BQPZD'9i,R4PFh3!RQ+!!"AV#J#3!i!!N!@QKUjrU!#3'[q
3"&4&@&483N)f!3#Xaj6bV-H8mJ!!!B3!N!0"!*!$[3#3!cR@iiY)!*!'[I%4!!J
Fp$X%X3@J!mZE6!GRiKUi$HGKMf0U61S46%i1"AB!TI,fLl!d1X3RDDE8ALfTCbM
8UP9p4iUqY-0k4krHpk9XK@`rbj2Ti'U@5rGH@+[fr-i4T6-qXpfl26,k!H5$Nml
TIkI'(l3GI4)f8mII&01CNEbC2LrNLBeaZ1HG@$G8!Z6"k)hh,q9p"r6FC*!!Se"
(ic,Pd(4(b`pflKC`H1&JN5)GVX3mREdH55[l`%`Yhp%q092c`A(hPV)!83Dr&f4
$$L#I1aM-"VjqV-q$34KQq6$M$f8#,Zc,i),!(`*ZN!$K$rS!LA%3cL+dYi"@,K(
Z"`#3!fKi!!!:


At the start of the file there must be a text line, which is used by users and tools to recognize BinHex versions: (This file must be converted with BinHex 4.0)

The rest of the file consists of three parts, a header (containing file name, size etc), a data fork (containing the file data) and a resource fork
Resource fork
The resource fork is a construct of the Mac OS operating system used to store structured data in a file, alongside unstructured data stored within the data fork. A resource fork stores information in a specific form, such as icons, the shapes of windows, definitions of menus and their contents, and...

. Each has a two-byte CRC
CRC
- Organizations :* California Rehabilitation Center, a state prison in the USA* Cambridge Regional College, a further education college* Cambridge Regional College F.C., a semi-professional football club in England* Canada Research Chair* Capital Research Center...

 checksum.

Everything except the (This file... is then seen as an area of binary data, which is encoded to ASCII characters. The encoding algorithm says that three bytes input are divided into four 6-bit values, in a similar way as Base64
Base64
Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation...

does it. Number 0-63 are given characters according to the following list !"#$%&'*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr

When encoding, a should be inserted after every 64 characters. After encoding, a colon is placed before and after the data.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK