Frontend Labs
⋯

0.5 The little bit of maths you need

Four ideas. Nothing more. Each is re-explained where used.

Idea 1 — Bits, bytes, and "key size"

A bit is 0 or 1. A byte is 8 bits (values 0–255).

A 128-bit key is 128 bits of secret — 2^128 possible values, which is about 3.4 × 10^38. That number is the entire reason symmetric crypto works:

   2^128 = 340,282,366,920,938,463,463,374,607,431,768,211,456

   A machine trying 1,000,000,000,000 (10^12) keys per second
   would need about 10^19 years to try them all.
   The universe is about 1.4 x 10^10 years old.

Brute force is not a threat to a 128-bit key. Every real attack works around the key, not through it. Remember that; it reframes everything.

Idea 2 — XOR

Exclusive-or. The one operation you must know.

   0 XOR 0 = 0        Rule: output 1 when the inputs DIFFER.
   0 XOR 1 = 1
   1 XOR 0 = 1
   1 XOR 1 = 0

   The magic property:   (A XOR B) XOR B = A

   plaintext  0110 1001
   key        1010 1100   XOR
              ---------
   ciphertext 1100 0101

   ciphertext 1100 0101
   key        1010 1100   XOR
              ---------
   plaintext  0110 1001    <-- back to the original

XOR with a key encrypts; XOR with the same key decrypts. That's the core of every stream cipher.

Idea 3 — Modular arithmetic ("clock arithmetic")

   On a 12-hour clock:  9 + 5 = 2       because 14 mod 12 = 2

   "mod n" means: divide by n, keep the remainder.
      17 mod 5 = 2        100 mod 7 = 2        6 mod 6 = 0

Public-key crypto works in enormous clocks — numbers hundreds of digits long. That's the only reason it's hard to reverse.

Idea 4 — One-way functions

A function that's easy forwards and impractical backwards.

   EASY:   multiply 1,048,573 x 1,048,583  = 1,099,483,725,059
   HARD:   given 1,099,483,725,059, find the two factors

   With 300-digit numbers, "hard" means "no known method finishes
   before the sun burns out".

All of cryptography is built on one-way functions. Hashing is one-way. RSA relies on factoring being one-way. Diffie–Hellman relies on discrete logarithms being one-way.

That's genuinely all

If those four made sense, you can read every chapter here. Where deeper maths appears it's marked optional and you can skip it.

Further reading (only if you want more)

  • Book: Serious Cryptography (2nd ed.) — Jean-Philippe Aumasson. The best bridge between "I know nothing" and real understanding. Almost no maths prerequisites.
  • Video: Computerphile's cryptography playlist — short, visual, excellent.
  • Interactive: cryptohack.org — free, gamified, teaches by doing.

Generated from real-life-guide.md · 8 Oct 2026 16:36