Pinterest Stumbleupon Whatsapp
Ads by Google

what is a hex editorThe term hex, short for hexadecimal or base-16, is the raw data structure that all files stored on your computer follow. Although literally every file is stored on your computer in this format, you almost never see this data anywhere. Yet being able to directly modify the raw bits and bytes in your computer can sometimes be used to your advantage.

So how does hex work, what is a hex editor and why might you need to use one on your PC?

What Is Hex?

The number system that humans use to count is called decimal, the numbers from 0 to 9. Decimal was invented by the Persians about 6000 years ago.

Fast forward to 1679. The binary number system made up of 0s and 1s was invented by Gottfried Wilhelm von Leibniz.

Finally in the 1950s or 1960s IBM formalized the Hexadecimal number system, which is a short way to represent binary data. Instead of using digits 0-9, hexadecimal uses digits from 0 to F. Counting from 0 to 31 (converting from decimal to hexadecimal):

Ads by Google

0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F

Once you reach the end of the numeric “digits”, you simply increase the number to the left by one, just like you do with the decimal counting system.

Now that we have the basics of hexadecimal out of the way, let’s move on to some hex editors.

Hex Editors

Hex editors differ from a regular text editors in a number of ways. The basis of a hex editor is that they display the raw contents of the file. No encoding or translation into text – just the raw machine code. The second is that line numbers instead of being based on “lines” are an offset address from the beginning of the file.

PSPad

what is a hex editor

My favorite hex editor is PSPad. PSPad, in addition to being a great text and code editor, offers the “Open in HEX Editor …” option which will launch the special editing mode.

Once you are in this mode, you can see the location and hexadecimal values of each bit of the file. You have two choices for editing the file – you can either edit the hexadecimal values by location, or on the right side you have the alphanumeric representation of that value which you can also edit.

XVI32

what is a hex editor used for

XVI32 is also a very capable hex editor. As with PSPad you can edit the hex values directly or the character representation.

It also has some advanced hex editing tools such as an address calculator for checking offsets and some other hex-specific options which can help you get around a hex file if you know what you are doing.

What Can You Do With A Hex Editor?

Now that you know what a hex value is, and how you can open and edit them, why would you want to do that exactly?

Find Out A File Type

Every once in a while you might come across a file that you just can’t seem to open. It has a normal size, but Word or Adobe won’t open it. So can you do anything about that?

The first thing I will do is open the file in a hex editor. Most files include some information in the very top of the file which describes what kind of file it actually might be.

Below, is a character representation of an Adobe PDF file. Let’s say someone mistakenly saves a PDF file as a Microsoft Word .DOC file.

what is a hex editor

When your system sees that extension, it will try to launch Microsoft Word to open the file – but it will fail. Open the file in a hex editor, and it is immediately clear that this file is indeed a PDF file, and a quick switch to the file extension and you will be able to open it right up in Adobe Acrobat or other proper reader.

If you see a filetype but have no idea what kind of program might be used to open that file, you might check out OpenWith which lists many file extensions and the programs used to open them.

Game & File Hacking

Another popular reason you might use a hex editor is game hacking. You can load up a game save state file and change the amount of money you have from $1,000 to $1,000,000, for example.

Now, on more recent games this has been made much harder. Many modern games include either compression or encryption which make it many times more difficult to decompile the save state or game. However, some games still allow you to edit certain variables, such as in Sonic Spinball.

In addition to looking into game files, sometimes you can glean other important information from a saved file that you otherwise might not have access to. This depends greatly on the type of file and what information you are looking for, but using a hex editor is useful in determining what exactly resides within a file.

Debugging & Editing

Finally the last main reason you might use a hex editor is if you are a programmer who is debugging your code. Instead of going back to recompile you code, a simple hex edit might be all you need to test out a verification pattern. Editing a raw binary file is not recommended for the feint of heart – modify just one character in a file could potentially render it useless. Make sure you have a backup before modifying any files using a hex editor.

When a Hex Isn’t a Hex

Hopefully you’ve learned a little bit about computers that you hadn’t known before, or at least have had your memory refreshed. Knowing how your computer ticks becomes more and more important as they become easier and easier to use. I know if you made it this far, you are ready to use these advanced strategies for getting the most out of the bits and bytes stored on your hard drive!

Have questions about hexadecimal or hex editors in general? Let us know below!

  1. Dansharif03
    May 3, 2011 at 4:25 pm

    Hi guys can someone pls help ? why should hex editor has to be used with extreme caution ?

    • Dave Drager
      May 4, 2011 at 6:24 pm

      The reason it should be used with caution is that if you make even one character change that is not correct, it could render the program inoperable. Always have a backup before you start hex editing a file! :)

  2. Peter Climes
    April 5, 2011 at 8:27 pm

    Actually, you are both right.

    Dave is right in that the system did indeed appear in use first within the Persian empire, while you are right in saying we have only because of Arabic advancements.

    The following is taken from an article published on the University of North Carolina site..

    "The modern system of numeration is based on place value, with the same symbol, such as 4, taking on different meaning (4, 40, 400, etc.) depending on its location within the representation of the number. Place value notation was used long ago in Babylonian cuneiform numerals, but our modern decimal place value system was invented by Hindu mathematicians in India, probably by the sixth century and perhaps even earlier. The modern numerals 1, 2, 3, ..., are sometimes called "Arabic" numerals in the West because they were introduced to Europeans by Arab scholars. The key figure was the great Arab mathematician Mohammed ibn-Musa al-Khowarizmi, who taught at Baghdad sometime between 800 and 850. He wrote a book on the Hindu number system known today only in a later Latin translation as De numero indorum, "On the Hindu numbers." Subsequently he wrote a longer and very influential work, Al-jabr w'al muqabalah, known in Europe as Algebra, which included all the techniques of arithmetic still taught in schools today. The author's name, Latinized as "Algorismus," is the root of the English word "algorithm".

    The Hindu-Arabic numeration system was known in Europe by 1000, but at first it didn't make much of a dent in the use of Roman numerals. During the 1100's the "Arabic" numerals were a topic of great interest among European scholars, and several translations of the Algebra appeared. In 1202, Leonardo of Pisa (ca. 1180-1250) published a famous book Liber abaci explaining and popularizing the Hindu-Arabic system, the use of the zero, the horizontal fraction bar, and the various algorithms of the Algebra. (Leonardo is better known today by his patronymic Fibonacci, "son of Bonaccio.") Thereafter modern numerals and the standard operations of arithmetic were commonly used by scholars, but Roman numerals continued to be used for many purposes, including finance and bookkeeping, for many centuries to come.

    Incidentally, the numerals 0123456789 are more properly known as European digits. The numerals actually used in Arabic script, the true Arabic numerals, are of different forms; see Islamicity.com for a more complete discussion."

    (See http://www.unc.edu/~rowlett/un... for the full article)

    But I have to agree with M.D's general remarks regarding the current popular "fad" to downplay all things positive about Arab or Muslim culture, achievements or influences. Their "fingerprint" has left its mark on the world in a very positive and beneficial way, in everything from science and architecture, to Music, Art and Food..and let's not forget to mention Philosophy.

    But I think it would be best to leave the subject rest here, as this is not the kind of forum/blog/site that covers such matters and I dare say we have already strayed far outside the remit of Dave's original article above..

    Peace & respect to you all..

    Peter C

  3. Peter Climes
    April 5, 2011 at 6:27 pm

    Actually, you are both right.

    Dave is right in that the system did indeed appear in use first within the Persian empire, while you are right in saying we have only because of Arabic advancements.

    The following is taken from an article published on the University of North Carolina site..

    "The modern system of numeration is based on place value, with the same symbol, such as 4, taking on different meaning (4, 40, 400, etc.) depending on its location within the representation of the number. Place value notation was used long ago in Babylonian cuneiform numerals, but our modern decimal place value system was invented by Hindu mathematicians in India, probably by the sixth century and perhaps even earlier. The modern numerals 1, 2, 3, ..., are sometimes called "Arabic" numerals in the West because they were introduced to Europeans by Arab scholars. The key figure was the great Arab mathematician Mohammed ibn-Musa al-Khowarizmi, who taught at Baghdad sometime between 800 and 850. He wrote a book on the Hindu number system known today only in a later Latin translation as De numero indorum, "On the Hindu numbers." Subsequently he wrote a longer and very influential work, Al-jabr w'al muqabalah, known in Europe as Algebra, which included all the techniques of arithmetic still taught in schools today. The author's name, Latinized as "Algorismus," is the root of the English word "algorithm".

    The Hindu-Arabic numeration system was known in Europe by 1000, but at first it didn't make much of a dent in the use of Roman numerals. During the 1100's the "Arabic" numerals were a topic of great interest among European scholars, and several translations of the Algebra appeared. In 1202, Leonardo of Pisa (ca. 1180-1250) published a famous book Liber abaci explaining and popularizing the Hindu-Arabic system, the use of the zero, the horizontal fraction bar, and the various algorithms of the Algebra. (Leonardo is better known today by his patronymic Fibonacci, "son of Bonaccio.") Thereafter modern numerals and the standard operations of arithmetic were commonly used by scholars, but Roman numerals continued to be used for many purposes, including finance and bookkeeping, for many centuries to come.

    Incidentally, the numerals 0123456789 are more properly known as European digits. The numerals actually used in Arabic script, the true Arabic numerals, are of different forms; see Islamicity.com for a more complete discussion."

    (See http://www.unc.edu/~rowlett/units/roman.html for the full article)

    But I have to agree with M.D's general remarks regarding the current popular "fad" to downplay all things positive about Arab or Muslim culture, achievements or influences. Their "fingerprint" has left its mark on the world in a very positive and beneficial way, in everything from science and architecture, to Music, Art and Food..and let's not forget to mention Philosophy.

    But I think it would be best to leave the subject rest here, as this is not the kind of forum/blog/site that covers such matters and I dare say we have already strayed far outside the remit of Dave's original article above..

    Peace & respect to you all..

    Peter C

  4. M.D.
    April 5, 2011 at 12:47 pm

    Wow!

    "Decimal was invented by the Persians about 6000 years ago."

    Really!

    1) This is clearly none relevant to the post .

    2) This is 100% FLASE! (& disinformation)
    Go do your own research if care about accuracy of information
    In short: A. Not Persians
    B. Zero was invented by Arabs, and Zero is a BIG deal!

    Stop your bias against Muslims/Arabs achievement in history, unfortunately this is widespread even in Wikipedia !

    Without their great & amazing contributions to humanity we would have been still in dark ages!

    By the way, Hindu numerals has noting to do with Arabic numerals ( the ones we use) any unbiased person would see that they don't even come close. Yet, the new fad is to write "Hindu-Arabic" numerals! Notice Hindu is written 1st!

    Their would not have been a computer if not for Al-Khwarizmi (who is a Muslim Arab and not Zoroastrian Persian!)

    It's funny that even though someone "race" (scientifically, there no such thing as race!) doesn't have to do with his achievement, in this case let us assume Al-Khwarizmi was Persian, yet it's been propagated everywhere like that will strip the fact that for him if he was not living in an Arabic country/Speaking Arabic & been a Muslim he would have never achieved what he had achieved period.!

    He's not even mentioned in High schools Algebra books (last time I checked)! even though he invented Algebra!

    Thus not creating any kind of appreciation/gratitude to the Arabs in the western culture!

    Why, well if you stole from someone almost everything (science etc) would you want to tell the world!

    Unfortunately, western society thrives of theft! Stealing knowledge, stealing countries etc etc !

    Grow up already !

  5. Jim
    March 17, 2011 at 2:53 am

    Thanks for replying, Dave. What exactly are "headers"? I've seen this term before but I'm having a hard time narrowing down how it relates to files via Google and DuckDuckGo. And I do understand your explanation above—that you have a broad market of readers; however, can you point me to a resource that can provide me with the information I am looking for? Email is fine, if you prefer to communicate that way : )

  6. Peter Climes
    March 16, 2011 at 3:16 pm

    Thanks, Dave, for the short intro/refresher on this subject..much appreciated!

    Just wondering..and this might be a stupid question to some reading this, but forgive me, I'm totally green when it comes to programming or debugging..but is it possible to hide a written message in a hex file without messing up the file in which the written text has been hidden?

    It seems to me it could or should be possible, but, like I said..I am totally green about such things. I ask as I'm a writer of the fictional sort and your article sparked off a basic storyline for a novel in my head about a guy who inadvertently finds a hidden message in a file while messing around with a Hex editor after reading an article such as yours.

  7. Peter Climes
    March 16, 2011 at 4:16 pm

    Thanks, Dave, for the short intro/refresher on this subject..much appreciated!

    Just wondering..and this might be a stupid question to some reading this, but forgive me, I'm totally green when it comes to programming or debugging..but is it possible to hide a written message in a hex file without messing up the file in which the written text has been hidden?

    It seems to me it could or should be possible, but, like I said..I am totally green about such things. I ask as I'm a writer of the fictional sort and your article sparked off a basic storyline for a novel in my head about a guy who inadvertently finds a hidden message in a file while messing around with a Hex editor after reading an article such as yours.

  8. Philharmania
    March 16, 2011 at 2:50 am

    You can also check HexEdit, which I believe is more powerful in hex manipulation compared with the software mentioned in the post.
    http://www.hexedit.com/download.htm

    • Dave Drager
      March 16, 2011 at 9:28 am

      This is another great recommendation for a hex editor!

  9. Philharmania
    March 16, 2011 at 3:50 am

    You can also check HexEdit, which I believe is more powerful in hex manipulation compared with the software mentioned in the post.
    http://www.hexedit.com/downloa...

  10. Jim
    March 15, 2011 at 3:04 pm

    Thanks for the excellent primer Dave!

    I'm assuming that when the alphanumeric interpretation looks scrambled or doesn't make sense, the data within the file has been encrypted/hashed or has had its redundant characters removed to decrease the size of the file (compression) as you say...
    Can you suggest what methods, disciplines, or techniques are available that will facilitate decryption or translation of scrambled text into meaningful human information? Perhaps a tutorial?!? The word "cipher" comes to mind but Im not sure it applies...

    • Dave Drager
      March 16, 2011 at 9:29 am

      That is definitely a more advanced topic that might go above what most MUOers would find useful. Typically it just means that like you said it is encrypted or hashed in some manner, either for compression or encryption. Sometimes you can figure out how it is done via the headers of the file but other times you need to 'brute force' it or find out some other way of detailing the algorithm used.

      • Jim
        March 17, 2011 at 1:53 am

        Thanks for replying, Dave. What exactly are "headers"? I've seen this term before but I'm having a hard time narrowing down how it relates to files via Google and DuckDuckGo. And I do understand your explanation above—that you have a broad market of readers; however, can you point me to a resource that can provide me with the information I am looking for? Email is fine, if you prefer to communicate that way : )

  11. Jim
    March 15, 2011 at 4:04 pm

    Thanks for the excellent primer Dave!

    I'm assuming that when the alphanumeric interpretation looks scrambled or doesn't make sense, the data within the file has been encrypted/hashed or has had its redundant characters removed to decrease the size of the file (compression) as you say...
    Can you suggest what methods, disciplines, or techniques are available that will facilitate decryption or translation of scrambled text into meaningful human information? Perhaps a tutorial?!? The word "cipher" comes to mind but Im not sure it applies...

  12. Jasjeev Singh Anand
    March 15, 2011 at 7:33 am

    But I'd like to find out some more stuff we can do with this.

  13. Jasjeev Singh Anand
    March 15, 2011 at 7:32 am

    Awesome read!

    • Dave Drager
      March 16, 2011 at 9:29 am

      Thanks! :)

  14. Bheeelaat
    March 15, 2011 at 4:09 am

    nice! we use it in opermini

Leave a Reply

Your email address will not be published. Required fields are marked *