2.2 Hexadecimal & ASCII

Key Takeaways

  • Hexadecimal is base-16: digits 0–9 and A–F; each hex digit is exactly one nibble (4 bits)
  • Convert binary↔hex by grouping bits in fours; convert hex↔decimal via place values 16¹ and 16⁰ (and higher powers for longer values)
  • ASCII maps characters to numeric codes: space=32, digit '0'=48, uppercase 'A'=65, lowercase 'a'=97
  • Cyber tooling often shows bytes in hex (0x4A, \x41); reading those dumps requires fluent nibble grouping
  • Exam traps: confusing ASCII letter codes with hex digit letters; forgetting that '0' is 48 decimal, not zero
Last updated: July 2026

Binary is precise but verbose. Hexadecimal (hex) compresses bit patterns into a human-readable form that cyber analysts, packet dumps, and crypto libraries use constantly. ASCII then maps those byte values to printable characters. Together, hex and ASCII let you read what a raw byte stream "means" on the Cyber Test and on the job.

Hexadecimal Basics

Hex is base-16. Digits run 0–9, then A–F (or a–f) for values 10–15. Prefixes like 0x or suffixes like h mark hex in many notations (0xFF, FFh).

Hex digitDecimalBinary (nibble)
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Critical rule: one hex digit ↔ exactly 4 bits (one nibble). Two hex digits ↔ one byte (8 bits). That is why MAC addresses, IPv6 hextets, and hash digests are written in hex — they map cleanly onto bit width.


Binary ↔ Hex via Nibble Grouping

Binary to hex

  1. Pad the bit string on the left with zeros until the length is a multiple of 4.
  2. Split into nibbles from the right (or left after padding — same groups).
  3. Replace each nibble with its hex digit from the table.

Worked example: Convert 11010110₂ to hex.

  • Groups: 1101 0110
  • 1101 = 13 = D; 0110 = 6 → 0xD6

Worked example: Convert 10101111001₂ to hex.

  • Pad to 12 bits: 0101 0111 1001
  • 5, 7, 9 → 0x579

Hex to binary

Expand each hex digit into its 4-bit pattern. Do not drop leading zeros inside a nibble — 0x0A is 00001010, not 1010 alone if you need a full byte.

Worked example: 0x3C0011 110000111100₂ = 60₁₀.

Hex to decimal (short values)

For two-digit hex XY: value = (X × 16) + Y.

  • 0xA5 = (10 × 16) + 5 = 160 + 5 = 165
  • 0xFF = (15 × 16) + 15 = 255 (full unsigned byte — same landmark as 11111111₂)

For three digits XYZ: (X × 256) + (Y × 16) + Z, since 16² = 256.


Why Cyber Candidates Live in Hex

  • Packet and memory dumps show bytes as hex pairs (4F 70 65 6E).
  • IPv6 addresses use hex hextets; nibble fluency transfers.
  • Crypto digests (MD5, SHA-256) are printed as hex strings — each two characters is one byte of the hash.
  • Bitwise masks in config files often appear as 0xFF00 rather than long binary.

If a dump shows 0x41, you should instantly think both "65 decimal" and "ASCII 'A'" — that dual reading is the point of this section.


ASCII: Characters as Numbers

ASCII (American Standard Code for Information Interchange) assigns integers to characters so text can travel as bytes. Classic ASCII uses 7 bits (0–127); in practice you see it embedded in 8-bit bytes (high bit often 0).

High-value code points to memorize

CharacterDecimalHexBinary (8-bit)Notes
space320x2000100000Word separator; common in parsers
'0'480x3000110000Digit zero — not numeric value 0
'1'490x3100110001Digits ascend: '0'+n
'9'570x3900111001End of digit range
'A'650x4101000001Uppercase start
'Z'900x5A01011010Uppercase end
'a'970x6101100001Lowercase = uppercase + 32
'z'1220x7A01111010Lowercase end

Patterns that save time

  • Digits: '0''9' are 48–57. The character '7' has code 48 + 7 = 55, not 7.
  • Case shift: lowercase = uppercase + 32. Flipping bit 5 (value 32) often toggles case in ASCII — a bitwise intuition you will reuse in section 2.3.
  • Letters: 'A' = 65, 'B' = 66, … so 'C' = 67 = 0x43.

Worked examples

  1. What character is ASCII 65? → 'A'.
  2. Byte 0x30 in a text stream? → character '0' (digit zero).
  3. Hex dump 48 69 → decimal 72, 105 → 'H', 'i' → string "Hi".
  4. Difference between 'a' and 'A': 97 − 65 = 32 (one bit in the byte).

Exam Traps

  • Hex letters vs ASCII letters: Hex digit A means ten. ASCII 'A' means code 65. Context decides.
  • Character '0' vs value 0: '0' is 48. Numeric zero as a byte is 0x00 (NUL), not the digit character.
  • Nibble mis-grouping: Grouping 11010110 as 110 10110 instead of 1101 0110 produces wrong hex.
  • Case in hex digits: 0xaf equals 0xAF; case of hex letters does not change value. Case of ASCII letters does.
  • Seven-bit vs eight-bit: Printable ASCII fits in 0–127; a byte 0xC2 is outside classic printable ASCII and often signals UTF-8 or extended sets — do not force it into 'A''Z' logic.

Study drill

Convert random bytes both ways: binary ↔ hex ↔ decimal, then ask "if this were ASCII, what character?" That triple fluency is what CT-style items reward.

Networking and crypto cameo

An Ethernet MAC might read 00:1A:2B:3C:4D:5E — each pair is a hex byte. A truncated SHA-256 preview e3b0c442… is also hex. You are not asked to compute hashes here; you are asked to read the encoding. Hex and ASCII are the shared language of those displays.

Test Your Knowledge

What is the hexadecimal representation of the binary value 10101111?

A
B
C
D
Test Your Knowledge

Which ASCII decimal code corresponds to the character 'A'?

A
B
C
D
Test Your Knowledge

A hex dump shows the byte 0x30. If interpreted as ASCII, which character is it?

A
B
C
D
Test Your Knowledge

What is the decimal value of hex 0xC8?

A
B
C
D