Free through lesson 3

Cryptography Fundamentals

From XOR and randomness to breaking classical ciphers, hashes and MACs, AES and authenticated encryption, Diffie-Hellman and RSA, signatures, and TLS with certificates. Over 30 lessons, you'll work up to breaking ciphers yourself and choosing the right way to use them on your own. The first half uses only Python's standard library; the second half uses the cryptography library and the openssl command.

about 3 hours in total (estimate)

Curriculum

The 30 lessons are split into 6 chapters. We recommend working through them in order starting from Chapter 1: each chapter fixes the schemes you broke in the one before. * The code in Chapters 1 and 2 uses only Python's standard library and runs right in your browser. From Chapter 3 on, install cryptography into Python 3 on your own machine (all output in this course was generated with Python 3.14.2). Lesson 1 shows how.

Chapter 1 — Before Cryptography (lessons 1–5)

Separate what cryptography can and cannot protect, and get hands-on with its raw materials: bytes, XOR, and randomness. You'll finish by breaking classical ciphers with frequency analysis, then reach the idea of keeping only the key secret through the one-time pad and Kerckhoffs's principle.

Chapter 2 — Hashes and MACs (lessons 6–10)

Detect tampering with hashes, then mix in a key with HMAC to confirm a message really came from the right party. You'll go on to signed requests, password storage, and HKDF for deriving per-purpose keys from one key, ending with the keys Chapter 3's encryption will need.

Chapter 3 — Symmetric Ciphers (lessons 11–15)

Run AES on a single block, then encrypt longer data with the ECB, CBC, and CTR modes. You'll see an image's shape survive ECB, find that encryption alone can't detect tampering, and watch nonce reuse take you right back to lesson 2, ending with authenticated encryption (AES-GCM and ChaCha20-Poly1305).

Chapter 4 — Public-Key Cryptography (lessons 16–20)

Starting from modular arithmetic and discrete logarithms, you'll write Diffie-Hellman yourself to share a key with a stranger over a line that's being watched. You'll walk through RSA with small numbers, learn to use it correctly, and finish with Ed25519 signatures that let anyone verify who made something.

Chapter 5 — TLS and Certificates (lessons 21–25)

Confirm that a certificate is a signature over a name and a public key, then build and verify a certificate chain with your own CA. You'll run a local HTTPS server, read a TLS 1.3 handshake, match up where each earlier chapter's parts are used, and check forward secrecy and verification failures.

Chapter 6 — Putting It to Use (lessons 26–30)

Decide where keys live and how to replace them, then build a passphrase-based file-encryption tool from the parts you've learned. Finally, gather the don'ts from all 30 lessons and the questions to ask when in doubt.

Once you've finished all 30 lessons, head to Blockchain Fundamentals Course to build a system on top of cryptography from scratch, or to Intro to Authentication & Membership Features to put it to work in sign-in and accounts. A membership unlocks every course.