01 A computer only knows two things
Inside your Mac there are billions of microscopic switches. Each one is either off or on. That is the entire alphabet. We write off as 0 and on as 1, and we call one switch a bit.
One bit alone is nearly useless. It can say yes or no and nothing more. So computers work with bits in groups of eight, and a group of eight is called a byte.
Eight bits give you 256 different combinations, which was enough to cover every letter, digit and punctuation mark that early English computers needed. The choice stuck, and now the whole world is built on it.
02 Building a number from bits
Each position in a byte has a value, and the values double as you move left. The rightmost bit is worth 1, then 2, 4, 8, and so on up to 128 at the far left.
To read a byte, you add up the values of every position that is switched on. That is all binary is. Click the switches below and watch the number change.
Try to make the number 65. You will need the 64 switch and the 1 switch. Notice what character appears when you get there.
Switch on the 64 and the 1, leave the rest off. That is 01000001 in binary, which is 65, which ASCII says is the capital letter A.
Check yourself
Which switches do you turn on to make the number 10?
03 Why nobody writes binary
Binary is correct but exhausting. The word "Hacker" in binary is forty-eight characters of zeros and ones. Nobody can read that.
So we use hexadecimal, or hex for short. Hex counts to sixteen instead of ten. After 9 it keeps going with letters:
| Hex | Means | Hex | Means |
|---|---|---|---|
| 0โ9 | 0โ9, same as normal | c | 12 |
| a | 10 | d | 13 |
| b | 11 | e | 14 |
| f | 15 |
Here is the reason hex won. One hex digit is exactly four bits, so two hex digits are exactly one byte. Always. That clean fit is why hashes, memory dumps, network captures and colour codes are all written in hex.
Reading a two-digit hex number
The left digit counts sixteens. The right digit counts ones. So 6b is six sixteens plus eleven, which is 107.
You will constantly see numbers written as 0x41. The 0x is not part of the value. It is just a flag meaning "the thing after me is hex". So 0x41 is 65.
Check yourself
What is 0x20 as an ordinary number?
04 From numbers to letters
A number like 72 is still just a number. Turning it into the letter H takes one more step, and that step is a lookup table called ASCII.
ASCII is not clever. Decades ago people agreed that 72 would mean H, 97 would mean a, and so on. Every computer follows the same list. That is the whole trick.
Three anchors are worth memorising, because you can work out most of the table from them:
| Character | Decimal | Hex |
|---|---|---|
| Capital A | 65 | 0x41 |
| Lowercase a | 97 | 0x61 |
| The digit 0 | 48 | 0x30 |
Lowercase always sits exactly 32 above its uppercase twin. So if A is 65, then a is 97. If H is 72, then h is 104. One bit is the only difference between a capital and a small letter.
Try it on your own words
Type anything below. Watch each character break into its character, hex, decimal and binary.
The puzzle 48 61 63 6b 65 72 spells Hacker. The 48 is a capital H because 0x48 is 72, which sits in the uppercase range. Everything after it starts with 6 or 7, which lands in the lowercase range.
Try it. The name of a file is a label. The first bytes are the truth.
05 Why this matters for security
This is not trivia. Reading raw bytes is a daily task in real security work.
- Malware hides its instructions. A virus that contains the text
delete everythingis easy for antivirus to spot, so attackers store it as hex or base64 instead, and rebuild it while running. - Evidence lives in raw bytes. A deleted file often still sits on the disk. Forensic investigators read the drive as raw bytes to recover it.
- File types are proven by their first bytes. Every PNG image begins with the same signature, no matter what the filename says. Renaming
virus.exetophoto.pngdoes not change what is inside. - Network traffic is bytes. When you inspect a captured packet later in Phase 00.4, you will be looking at exactly this.
Hex looks scrambled, so people assume it is protected. It is not. Hex is a costume, not a lock. There is no key and no secret, and anyone can reverse it in one second. Turning something into hex provides zero security. Lesson 00.5 makes this distinction properly.
06 Do it on your real machine
Playgrounds are useful, but you should see this work in a real terminal too. Open the Terminal app on your Mac (press Command and Space, type Terminal, press Enter) and run these.
Turn the number 65 into binary, hex and a character:
python3 -c "print(bin(65), hex(65), chr(65))"
Turn text into raw hex bytes:
echo -n "Hi" | xxd
Turn hex back into text:
echo -n "48 61 63 6b 65 72" | xxd -r -p
See the three anchor characters and the gap of 32 between cases:
python3 -c "[print(f'{c} dec={ord(c):<4} hex={ord(c):02x}') for c in 'AaHh0']"
Your checklist
- Built the number 65 with the bit switches and saw the letter A appear
- Can explain why two hex digits equal exactly one byte
- Know the three anchors: A is 65, a is 97, the digit 0 is 48
- Ran all four commands above in the real Terminal
- Can say out loud why hex is not encryption
07 Final check
Question 1 of 3
A file is 4 bytes long. How many bits is that?
Question 2 of 3
You see 0x61 in a memory dump. What character is it?
Question 3 of 3
An attacker stores a command in a file as hex instead of plain text. What has this achieved?
A bit is a switch. Eight bits make a byte. Binary adds up powers of two. Hex packs four bits per digit, so two digits make a byte. ASCII maps those numbers to characters. And encoding is a costume, not a lock. That is the foundation for everything ahead.
✓ Key takeaways
The things from this lesson worth carrying into the next one. If you remember nothing else, remember these.
★ Carry these forward
- Capital A is 65 (0x41), lowercase a is 97 (0x61), and the digit 0 is 48 (0x30). Lowercase always sits exactly 32 above its uppercase twin.
- One hex digit covers 16 values, which is 4 bits. Two digits are 8 bits, and 8 bits is a byte. That clean fit is why hashes and memory dumps use hex.
- It defeats a lazy scanner searching for suspicious words, but gives zero protection. Hex is a costume, not a lock, and anyone can reverse it instantly.
⚑ Keep going
You have read it and tried it in the lesson. Now cement it. These three do more for retention than re-reading ever will.