It has turn into clear from a few of your questions that fairly a couple of of you’re unfamiliar with the hexadecimal system, or just, hex. The hexadecimal system is used all through computing and in case you have by no means studied this Base16 numering system, it might seem comparatively opaque.
For these of you who might have been overwhelmed by this seemingly mysterious numbering system, I dedicate this transient introduction and overview of the hexadecimal numbering system.
As you already know, you encounter the hexadecimal system all through your laptop and software program. It often seems to be some factor like this 0x4D or just 4D. Instantly, you acknowledge one thing is totally different right here as a result of first, it usually begins with that unusual 0x, and second, there are letters in there and never simply the digits (0-9).
We’ll usually encounter hex in onerous drive photos akin to in digital forensics akin to beneath.
Or we would additionally encounter hex whereas utilizing Wireshark, like beneath.
And we’re very prone to encounter hex in studying our IDS alerts akin to in Snort, like that beneath.
Among the many most essential causes to know and examine hex is that our MAC addresses on all NICs and community gadgets are all in hex, and IPv6 will ALL be in hex, as soon as it’s broadly adopted.
If you’re not conversant in hex, that is the time to take a couple of minutes to attempt to perceive it. A couple of minutes now will probably prevent hours of complications later.
Our Decimal System
Probably the greatest methods to return to know the Base16 or hexadecimal system is to return to the fundamentals of a numbering system you’re very conversant in, the Base10, or decimal system. In that system, we’ve 10 digits (0-9) and every column in that system represents a worth 10 instances higher than the one to the fitting of it. So, as an example:
31337
Represents (beginning on the fitting and shifting left):
7 ones (1)
3 tens (10)
3 tons of (100)
1 thousand (1000)
3 ten hundreds (10,000)
Every place holder is 10 instances bigger than the earlier one. The hex system works equally, however every column is 16 instances bigger than the earlier column. So, the primary 4 hex columns have values like this:
4096 256 16 1
Every is 16 instances higher than the column to its proper.
The Hex Numbering System
The hex system is a base16 numbering system. Just like the decimal or Base10 system, the hex system has to have 16 digits to cowl all the chances. Sadly, we solely have 10 to work with (0-9), so we have to add six extra. The pc business has determined to make use of the letters A-F to symbolize these further values. Which means that the hex system has the next values.
0 = 0
1= 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
Which means that once we see a hex illustration of a quantity akin to:
0x45
We are able to consider it equally to a decimal quantity besides the second column represents 16s and never 10s. Which means that 0x45 in hex might be evaluated akin to:
5 x 1 = 5
4 x 16 = 64
—————
= 69
If we’ve a hex quantity akin to DE, we are able to calculate its worth this fashion:
D represents 13 x 16 = 208
E represents 14 x 1 = 14
————————————–
= 222
Why We Use Hex
In computing, a bit is a single on/off swap usually represented by a 0 or a 1. A byte is eight bits usually represented by 0000 0000. A byte is a vital unit in computing because it usually used to symbolize an ASCII character or a single octet in an IP tackle, amongst many different issues. The vary of numbers that one byte can symbolize is 0-255 or 256 values. That’s the reason in our IPv4 addresses, every octet (byte) has a worth from 0-255, such 192.168.0.254 with a netmask of 255.255.255.0. Observe me?
Most people have a tough time working within the Base2 system that underlies our laptop programs. Base2 numbers is likely to be represented like this:
1101 1100
Athough this quantity represents 2220 in decimal, the conversion to decimal shouldn’t be easy or intutive.
The hex system permits us to symbolize the values of a single byte with simply two digits as the 2 digit hex values additionally vary from 0 – 255. Hex is extra compact than the Base2 system and it seems to be and acts much more just like the decimal system than Base2. As well as, each worth that may be represented by a byte might be represented in hex by the values between 0x00 – 0xFF (255).
Hex Math
In all probability the best option to do hex math is to make use of the calculator constructed into each Home windows system. Open the Home windows calculator like beneath:
Now, go to the View menu on the high and select “Programmer“.
As you’ll be able to see on the left facet of the calculator about halfway down, there are 4 buttons, Hex, Dec, Oct, Bin. By default, it ought to be set to Dec or Decimal, our acquainted Base10 system. If I wish to enter a hexadecimal quantity, merely click on on Hex after which enter the quantity.
After I accomplish that, I can then toggle to the Dec button and it’ll convert my hexadecimal quantity to a decimal quantity.
Lastly, if we wish to add, subtract, multiply or divide in hex, we are able to use the Programmer view within the Calculator as nicely. That’s, is we wished to add the hex worth DE to the hex worth A5, we merely enter DE within the calculator press the addition (+) after which enter the A5 after which press equal. The outcome can be 183 in hex.
After which we are able to toggle to the Dec button and get the decimal equal or 387.
Hope this transient tutorial on hex is useful!