Hexadecimal

Lazy Bastard
Hexadecimal is the numerical system that most hacking platforms work in. Therefore, it is very useful to have a basic understanding of hex, as it is commonly called.


-Hexadecimal?

The system we use in our everyday lives is called the decimal system. Its digits are from 0 to 9. In the hexadecimal system, the digits go from 0 to F. There are ten digits (counting 0) in the decimal system: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. In hexadecimal, there are 16 (counting 0): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. You can see that A represents 10, and, by counting, that F represents 15.


-Can I have a complete hexadecimal/decimal conversion chart?

No. Heheh. In order for me to make one, I would have to type in 65,535 different combinations and their decimal equivalents, and that's only to FFFF. I will, however, give you a chart which should, if you pay attention, easily suffice; hexadecimal on the left, decimal on the right.

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

10=16
11=17
12=18
13=19
14=20
15=21
16=22
17=23
18=24
19=25
1A=26
1B=27
1C=28
1D=29
1E=30
1F=31
20=32

30=48
40=64
50=80
60=96
70=112
80=128
90=144
A0=160
B0=176
C0=192
D0=208
E0=224
F0=240

100=256
200=512
300=768
400=1024
500=1280
600=1536
700=1792
800=2048
900=2304
A00=2506
B00=2816
C00=3072
D00=3328
E00=3584
F00=3840

1000=4096
2000=8192
3000=12288
4000=16384
5000=20480
6000=24576
7000=28672
8000=32768
9000=36864
A000=40960
B000=45056
C000=49152
D000=53248
E000=57344
F000=61440

Now let's look at some combinations of high hexadecimal numbers...

AA00=43466
AAA0=43626
AAAA=43636

BB00=47872
BBB0=48048
BBBB=48059

CC00=52224
CCC0=52416
CCCC=52428

DD00=56576
DDD0=56784
DDDD=56797

EE00=60928
EEE0=61152
EEEE=61166

FF00=65280
FFF0=65520
FFFF=65535

You will use this chart further on in this FAQ, so take a good look at it and make sure you at least have a basic understanding of it.


-Are there any basic rules in hex?

There are quite a few, as in any numbering system. I will explain only two which I have found useful here. First, any decimal (our system, as I've said) number that is divisible by 16 (meaning it can be divided by 16 and come out with a whole number) can be easily converted to hex. Simply divide that number by 16, then multiply by 10. Here is an example:

I have 64, and want to know what 64 is in hexadecimal.

64 divided by 16 = 4

4 X 10 = 40

64 in hex is 40.

Understand? Hopefully, because I'm moving on to another one, heheh. If you want to add a zero to a number in hexadecimal, for example 10 hex, making it (in this example) 100 hex, and determine its new decimal equivalent (assuming, of course, you know the decimal equivalent of the original number), you DO NOT multiply the decimal equivalent by ten, as in our system. The reason you multiply by ten in our system is that in our system, there are ten individual digits, 0-9. In hex, there are 16, 0-F, therefore you must multiply by 16.

16 X 16 = 256

Therefore, 100 hex = 256 dec

Here's another example:

3B = 59

3B0 = ?

To find the decimal equivalent of 3B0, you must multiply the decimal equivalent of 3B by 16.

59 X 16 = 944

Therefore, the decimal equivalent of 3B0 is 944.


-How do I add in hex?

To add in hex, simply add in hex, heheh. Here's an example:

B + 7 = 12

Look at the chart. This is because B = 11 in decimal, and 7 obviously = 7 in decimal, and 11 + 7 = 18, which in hex is 12. Here's another example:

5 + 4 = 9

This is simple math; nothing is any different here than what the teacher taught you in kindergarten.


-How do I add larger numbers in hex?

There are two ways I know of (that are feasible) to manually add in hex with large numbers. There are, I'm sure, a few others, but they are far too complicated to ever have any desire to use, especially when you'll get the same answer using these. Say our numbers are 35B and 64C, and we wish to add them together. Here are the two ways we could do that:


-The hard way

Using this method, you will first find the decimal equivalent of each hexadecimal number (use your chart), in this case the decimal equivalent of 35B and 64C. To do this, start by finding the decimal equivalent of the first digit of the first number. In this example,the first number is 35B, and the first digit of it is 300.

300 in decimal = 768


Next, find the equivalent of the second digit, 50.

50 in decimal = 80


Finally, find the equivalent of the last digit, B.

B in decimal = 11


Now, add them all (the equivalents) up.

768 + 80 + 11 = 859


Therefore, 35B hex = 859 decimal.


Next, move on to the second number, 64C. Start with the first digit, as always.

600 in decimal = 1536


Next, as always, the second digit.

40 in decimal = 64


Finally as always, the last digit.

C in decimal = 12


Now (as always, heh), add all the equivalents together.

1536 + 64 + 12 = 1612


Now add both sums together.

859 + 1612 = 2471


Now you must find the hexadecimal equivalent of 2471. The easiest way to go about doing this is to use the chart.

You know that 900 in hex = 2304, which is lower than 2471. And A00 in hex = 2506, which is higher than 2471. Therefore, the hex equivalent of 2471 is somewhere between 900 and A00. Now, find the difference between 2471 and the number below it that is the closest number to it that you know of; in this case 2304 (from 900).

2471 - 2304 = 167

167 in hex = A7 (use your chart and some simple addition)

Now add A7 to the hex version of the number below 2471 (2304), which is 900.

900 + A7 = 9A7

And there's your answer.

35B + 64C = 9A7


-The easy way

Simply break down each number by digit, staying in hex for the entire problem, 35B on the left, 64C on the right, and add the individual digits together as I have done below.

300 + 600 = 900

50 + 40 = 90

B + C = 17

Then add the three sums together.

900 + 90 + 17 = 9A7

If you do not see why, look at your chart, and I'll explain as best I can.

900 + 90 = 990

90 + 17 = A7

900 + A7 = 9A7


-Is there a basic formula for conversion, so that I might understand why _ in hex = _ in dec?

Yes, actually, there is, as there must be for it to be a real numbering system coexisting parallel to decimal.

I discovered, while studying binary numbers and their conversion to decimal counterparts, that the same system of equations, representing place values and the numerals occupying them, that is used to convert binary to decimal, would work with not only conversion between any other numbering systems, but also, and obviously, with any numbering system by itself. Here is a quick explanation, in decimal:

The decimal number 1234 represents not only a finite number of theoretical objects (discounting a host of other possibilities of its representation), but it also represents an equation. It is as follows (^ represents exponentiation, as in "Squared, to the third power", etc, and remember that any number to the 0th power is 1):

1234 =

(1 x 10^3) + (2 x 10^2) + (3 x 10^1) + (4 x 10^0) =

(1000) + (200) + (30) + (4) = 1234

Here's another example:

567 =

(5 x 10^2) + (6 x 10^1) + (7 x 10^0) =

(500) + (60) + (7) = 567

The reason that the number is multiplied by an increasing power of ten is that decimal is ten-base. Were it sixteen-base, as hexadecimal is, you would multiply by an increasing power of 16. Now, for this next part you might have to stretch your mind a little, unless you're like me and enjoy wierd, abstract ideas. The reason for the exact exponent of ten that you may observe, for example, in the number 567 (look up, if you've forgotten already, heh), is as follows:

The number 7 is in the ones place. 10 (along with ANY other number) to the 0th power is 1. The number 60 is in the tens place. 10 to the 1st power is in the tens place. Finally, the number 500 is in the hundreds place. 10 to the 2nd power is in the hundreds place. Now you see a pattern, and now I realize that I was wrong; you didn't have to stretch your mind, heheh. Now that you hopefully understand how this system works, I'll move on to the actual use of it. This is where you have to use your new-found (or not) knowledge of hex to understand. Let us take the hex number FEDC, and convert it to dec using simple knowledge of conversions of single-digit numbers between hex and dec. Pay attention to everything here, and remember that 10 hex = 16 dec:

hex- FEDC
hex- (F x 10^3) + (E x 10^2) + (D x 10^1) + (C x 10^0) =
dec- (15 x 16^3) + (14 x 16^2) + (13 x 16^1) + (12 x 16^0) =
dec- (15 x 4096) + (14 x 256) + (13 x 16) + (12 x 1) =
dec- (61440) + (3584) + (208) + (12) =
dec- 65244

And if you use one of the other two methods to check this work, it is correct. The only thing limiting you from actually using this method regularly is the fact that numbers as large as these are not easily multiplied and added in your head, and I doubt you want to waste massive amounts of paper in this endeavor. This is the reason I have shown you the other methods. This method is just a way of helping you understand what exactly you're converting. Have fun, and may you find it, if not useful, at least interesting.

Well, that's all that comes to mind. Hopefully it is all at least semi-clear to you now. I hope this info helps you to, at least to some extent, better understand how codes work.

If you have any further questions on hexadecimal, please feel free to e-mail any one of us on the GSHI staff.



This text was brought to you by GSHI.org, unless someone else gave it to you, in which case it was only written by someone at GSHI.org. Heheh.