Phase 00 ยท Foundations ยท Lesson 1

How computers store everything

Every password, photo, message and virus on Earth is the same thing underneath: a long row of numbers. Once you can read those numbers, a lot of security stops being magic.

โฑ 25 minutes ๐Ÿ“Š No experience needed ๐Ÿงช 3 playgrounds

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.

๐Ÿ’ก
Why eight?

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?

8 + 2 = 10. There is no "10 switch" because the positions only ever hold powers of two: 1, 2, 4, 8, 16, 32, 64, 128. Every number you can imagine is built by adding some of those together.

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:

HexMeansHexMeans
0โ€“90โ€“9, same as normalc12
a10d13
b11e14
f15

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.

๐Ÿ”ข
The 0x prefix

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?

Two sixteens plus zero ones is 32. Remember this one, it turns up constantly: 32 is the space character, and it is also the exact gap between an uppercase and a lowercase letter.

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:

CharacterDecimalHex
Capital A650x41
Lowercase a970x61
The digit 0480x30

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.

โœ…
You have already done this

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 everything is 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.exe to photo.png does 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.
๐Ÿšจ
The mistake beginners make

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?

One byte is 8 bits, so four bytes is 4 ร— 8 = 32 bits. It would also be written as 8 hex digits, since each byte takes two.

Question 2 of 3

You see 0x61 in a memory dump. What character is it?

0x61 is six sixteens plus one, which is 97, and 97 is lowercase a. That was one of your three anchors.

Question 3 of 3

An attacker stores a command in a file as hex instead of plain text. What has this achieved?

This is the important nuance. Hex is not encryption, so it gives no real protection. But it does defeat a lazy scanner that just searches files for suspicious words. That is precisely why defenders must decode before they judge.
๐ŸŽ“
What you now know

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

  1. 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.
  2. 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.
  3. 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.