ArticleslgStudy

computer science

BinHex

BinHex is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand BinHex rather than just read about it. In short: BinHex, originally short for "binary-to-hexadecimal", is a binary-to-text encoding system which was used on the classic Mac OS for sending binary files over email. BinHexed files take up more space than the original files, but avoid data corruption by software that is not 8-bit clean.

Key takeaways

  • BinHex belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect BinHex to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of BinHex from memory before moving on to harder problems.

Reference excerpt

BinHex, originally short for "binary-to-hexadecimal", is a binary-to-text encoding system which was used on the classic Mac OS for sending binary files over email. BinHexed files take up more space than the original files, but avoid data corruption 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 computer, as a standalone version of the encoding scheme of the popular terminal emulator ST80-III, for users of other terminals. It was used for sending files via major online services such as CompuServe which, not being 8-bit clean, required files to use ASCII armoring 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 digits and letters (0–9, A–F), and adding a newline after every 60 characters. The system quickly gained the addition of a checksum at the end of every line to check for errors, and a subsequent conversion to use the BASIC/S compiler allowed it to run much faster than the original interpreted version. BinHex files of the era were typically given the file extension .hex. Ports soon appeared for other popular computers of the era, including the Apple II. 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" 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 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 .hcx, 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 in BASIC. This version performed the following sequence of operations:

Generate cyclic redundancy checks (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 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 information in the header being protected from corruption by no longer being in plain text. The file extension for this new format was .hqx. 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 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 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 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 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 (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!!!:

References

Citations Faltstrom, P.; Crocker, D.; Fair, E. (December 1994). MIME Content Type for BinHex Encoded Files. IETF. doi:10.17487/RFC1741. RFC 1741. Lempereur, Yves (25 November 1997). "Re: Prehistory of BinHex". Lewis, Peter N. (August 1991). "BinHex 4.0 Definition". Mann, Tim (1997). "Prehistory of BinHex".

See also Binary-to-text encoding for a comparison of various encoding algorithms

External links BinHex 4.0 at Macintosh Repository

Worked examples

Example 1 — a first encounter with BinHex

Start with the simplest possible case. Write down what BinHex claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to BinHex before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about BinHex ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of BinHex

In research
BinHex appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses BinHex in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
BinHex is common in secondary-school and first-year university syllabi. It links to neighbouring topics Archive formats, Binary-to-text encoding formats, Computer-related introductions in 1984, so understanding it makes those chapters shorter.
In everyday life
Look for BinHex outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “BinHex” →

How to study BinHex in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what BinHex means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain BinHex out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is BinHex in simple terms?

BinHex, originally short for "binary-to-hexadecimal", is a binary-to-text encoding system which was used on the classic Mac OS for sending binary files over email. BinHexed files take up more space than the original files, but avoid data corruption by software that is not 8-bit clean.

Why does BinHex matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study BinHex?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on BinHex.

Tags

  • Archive formats
  • Binary-to-text encoding formats
  • Computer-related introductions in 1984

Keep exploring