攻破玩具密码:应用密码学入门

Breaking Toy Ciphers: A Hands-On Intro to Applied Cryptography

You use HTTPS/JWT daily but never opened the box — from frequency-analysis cracking to a toy RSA you write yourself

6 labs10 AI-mentored sessions~5 hoursBilingual · EN / 中
Start learning →

About this course

A break-it-then-build-it course: no memorizing definitions, no proof-grinding. In every
session an AI mentor walks you through writing an attack, running it, and watching ciphertext
shatter into plaintext in front of you. We start by cracking the weakest toy ciphers —
single-byte XOR falls to frequency analysis in a blink, a repeating key gives away its length
to Hamming distance, a padding oracle decrypts without ever holding the key — so your intuition
grows out of the thrill of breaking things. Once you've broken enough, you turn around and build:
a toy RSA from scratch, a Diffie-Hellman handshake, hashing and HMAC, plus faithful re-creations
of real-world attacks like the e=3 cube root, length extension, and CBC bit-flipping. Everything
is pure-Python stdlib, offline, sub-second, and deterministic — every line you run is one you wrote.
By the end you'll finally know what's inside the box of the HTTPS, JWT, and signatures you use daily.

What you'll learn

  • Auto-crack single-byte and repeating-key XOR with frequency analysis, and see why a small key space always falls
  • Implement a toy RSA from scratch (fast modular exponentiation + extended Euclid modular inverse) and reproduce the e=3 cube-root attack
  • Hand-build a Diffie-Hellman handshake, then stage a man-in-the-middle attack to see why authentication is mandatory
  • Write a toy hash and HMAC, reproduce a length-extension forgery, and explain why HMAC stops it
  • Open the box on the HTTPS/JWT/digital signatures you use daily and explain how the pieces fit together

Syllabus

1Attack-Driven: from Cracking to Public-Key Crypto4 sessions
  • 1Crack Your First Cipher: XOR and Frequency Analysis30 minStart →
  • 2Repeating-Key XOR: Measuring Key Length with Hamming Distance30 minStart →
  • 3Toy RSA: Build a Public/Private Key Pair from Scratch30 minStart →
  • 4The Cube-Root Attack: Why Padding Is Not Optional30 minStart →
2Modular Magic: Key Exchange and the Man in the Middle3 sessions
  • 1Fast Modular Exponentiation: the Engine Behind Big-Number Crypto30 minStart →
  • 2Diffie-Hellman: Agreeing on a Secret over an Open Channel30 minStart →
  • 3Man in the Middle: an Unauthenticated Handshake Gets Hijacked30 minStart →
3Hashing & Integrity: Fingerprints, MACs, and Length Extension3 sessions
  • 1Hash Functions: Squeezing Any Data into a Fingerprint30 minStart →
  • 2Message Authentication and the Length-Extension Attack30 minStart →
  • 3HMAC: the Right Way, Plus a Timing Attack30 minStart →
4Block Ciphers & Modes: ECB in the Nude and the Padding Oracle0 sessions

Sessions are on the way.

5The Illusion of Randomness: Cracking PRNGs and Weak Seeds0 sessions

Sessions are on the way.

6Opening the Box: the Signatures, JWTs, and Handshakes You Use Daily0 sessions

Sessions are on the way.

Same series · 计算机科学与工程探索

CS & Engineering Explorations

Build from scratch the systems you usually treat as black boxes — and understand them to the core.