Why do you need a hex editor?

To cut a long story short: A hex editor is a program that lets you edit files at a low-level basis. Hex editors are byte oriented, they show you the physical contents of files (i.e. each individual byte).

In contrast, high-level applications (like word processing software) are representing the logical, not the physical contents of files. If you mark a word as bold, you're not interested in the physical coding within the file.

Here's the long answer. Some time ago, I received the following e-mail:

Hello,

First of all Thank You for your Free Hex Editor.

I have never used one nor do I know exactly what it is for But 2 people at alt.comp.freeware told me to get one so I could "see" the watermark/invisible imprint that a jpg compressor puts in the jpg's I compress!

Now that I have your program (Thank You again)....

What is a hex editor? Why do I need one (beside the above problem)? How do I change the imprint I found....thanks to your program?

Here's my attempt to answer these questions:

A hex editor is mainly a tool to examine the physical (i.e. byte per byte) structure of files. For every programmer (like me) this is an almost daily duty, but for "normal" users this may sound strange. But consider so called "plain text" files like the ubiquitous README.TXT files, created e.g. using notepad (without any layout like bold formatted words etc). They don't contain only the plain text, but also end-of-line marks (and often tabstops). Unfortunately, these end-of-line marks (not visible itself in notepad, you'll see only the breaking line) are coded differently under Windows, Unix, and Macintosh. If you happen to get a Unix or Mac text file from the net, it may cause problems under Windows (e.g. it will not show properly in notepad). Using XVI32 or any other hex editor, you can look into the file, examine the end-of-line marks and replace them if necessary (using Search | Replace | Replace all).

Just open the README.TXT file that comes with XVI32. The first 30 characters are looking in the hex area as follows:

48 65 78 2D 65 64 69 74 6F 72 20 58 56 49 33 32
20 76 65 72 73 69 6F 6E 20 31 2E 35 0D 0A

These are the hexadecimal codes for each byte. The hexadecimal system is similar to our common decimal system (which has the digits 0, 1, ... 9), but with the additional digits A, B, C, D, E, F - and the meaning of those digits 10, 11, 12, 13, 14, 15. To write the number 10, you need two digits in the decimal system, but in the hexadecimal system one digit A is sufficient.

In the decimal and hexadecimal system, the weight of a digit depends from its position within a number. With each position, the weight of a digit is incremented by factor 10 (or 16). The decimal number 72 e.g. consists of the digit 7 (with weight 7 * 10) and digit 2 (with weight 2 * 1), i.e. the value of 72 is 7 * 10 + 2 * 1. This may seem trivial to you, but consider now the hexadecimal system: the hex number 48 stands for 4 * 16 + 8 * 1 = 72.

When you've openend README.TXT in XVI32, the decimal value of hex 48 is displayed in the status line behind "Char dec:". The hex code 48 represents the capital letter H. There are 256 possible values for each byte ranging from decimal 0 to 255 (or hex 0 to FF). These 256 "characters" comprise the 26 capital letters, 26 small letters, 10 digits, special characters e.g. like the German Umlaute, but also non-printable control codes.

The last two bytes above (0D 0A = decimal 13 10) represent a line break for Windows. If I had created this README.TXT under Unix, you would see only 0A. Try to download several HTML files (which are plain text in opposite to binary files like JPG, GIF etc. which have non human-readable contents) from the web and look for the end-of-line mark. Mostly you'll find 0D 0A, but sometimes 0A, depending from their origin (and the transfer mode to your PC). To convert Unix text files to Windows format, you need to change all occurrences of 0A by 0D 0A.

Use XVI32 to open a document created with a word processor: You'll see many information besides the text itself (like previously deleted text, your name, the complete path to your document and so on).

BUT BE CAREFUL: Changing the contents of binary files may make them completely useless! Don't blame me if improper use of XVI32 will damage a valuable file!

So you need hex editors for mainly two reasons:

  1. Examining the physical structure of a file, because you don't see the bytes stored in a file using the regular application to open it (this is true also for so called "plain text" files as explained above). You need this knowledge e.g. to write by yourself an application that will interpret the contents of a file properly.
  2. Changing the contents of a file deliberately. This also requires to know exactly the file structure. If you don't know how watermarks are stored in JPGs, don't tamper with them - aside from the fact that it would be illegal to delete Copyright information.
I hope this helps and will be a starting point for further investigations done by yourself. But always remember: be careful to change file contents!

Tip: In contrast to Notepad, WordPad is working with all three mentioned kinds of text files!

[Back to XVI32 home]