Start here¶
Level: 101 · for anyone starting from zero
One line: Thirteen chapters, four checkpoints, and one idea repeated until it is obvious — cryptography does not make a secret, it moves one, and every chapter is about a different place the secret has been moved to.
What this library is for¶
To be able to read a system — a login, a TLS connection, a signed token, an encrypted column in a database — and say what is protecting what, against whom, and what would have to go wrong. Not to write cryptographic primitives. The pages that implement one implement it to be read, and they say so.
If you want the shortest possible version of why that distinction matters: the primitives are the strongest part of the whole field, and virtually every real break is somewhere else. AES is twenty-five years old and unbroken. The bugs are nonces that repeated, randomness that was not random, comparisons that returned early, keys that were checked into a repository, and protocols that could be talked down to their weakest option.
The four checkpoints¶
You have got what this library is for when you can do these four things without looking anything up. Each one has a chapter that ends at it.
| # | You can… | Reach it in |
|---|---|---|
| 1 | Say what a key is, what a nonce is, and what breaks when either one repeats | 01, 03, 05 |
| 2 | Tell hashing, MACs, and encryption apart — and say which of confidentiality, integrity and authenticity each one actually gives you | 04, 06 |
| 3 | Do a Diffie–Hellman by hand with small numbers, and say exactly what an eavesdropper who saw everything still does not have | 07 |
| 4 | Read a real system — a TLS handshake, a JWT, a password store — and name what is protecting what | 09, 10 |
Checkpoint 2 is the one most people fail without noticing, because the everyday word for all three is "encrypted".
The reading order, and why it is this one¶
Chapters 1–2 give you the vocabulary and one thing you can break. Starting with a cipher you can defeat with a pencil is not nostalgia: breaking one is the fastest way to learn what a key has to be, and why "nobody knows my algorithm" is not a plan.
Chapters 3–4 are the two ingredients everything else is built from — unpredictable bits, and a one-way function. They come before any cipher because a cipher with predictable keys is not a cipher, and because a hash is the piece most often mistaken for encryption.
Chapters 5–7 are the primitives themselves, in the order the secret moves: one shared key, then a key that only authenticates, then two keys of which one is public.
Chapters 8–9 assemble them into the two things you actually meet: a password store and a protocol.
Chapter 10 is the point of the whole thing. Everything before it works. This is where it is put together wrongly, which is where the field's actual failures live.
Chapters 11–13 are context — what it looks like in a job, where it came from, and what is arriving.
How to work a lesson¶
- Read the
**One line:**. If it is not the thing you wanted, the chapter README has the map. - Run the example before you read the output block. Every page's fenced output is generated from a real run, so it will match — the point is that you saw it happen.
- Do the "Try it" without the machine. Most of them are one number or one sentence, and they are the difference between having read a page and knowing it.
- Follow the "do not use this" line. On any page that implements a primitive, that sentence names what to reach for in real code. It is the most immediately useful line on the page.
Everything runs with what you have: python3, bash, openssl, and (optionally) rustc. Nothing to install, nothing to pip.
What this library will not do¶
- It will not teach you to implement production cryptography. That is a different craft, mostly about side channels and code review, and the honest advice is: don't.
- It will not give you a rating of algorithms. "Which is best" is nearly always the wrong question; "what is this protecting, and from whom" is the right one, and it has a different answer per system.
- It will not repeat the sibling libraries. Bytes, hex, encodings and UTF-8 are next door ↗, and this library links rather than restates. If a page here says "these bytes", that page assumes you can read a hex dump.
See also¶
- ROADMAP.md — what is written, what is a stub, what is next
- GLOSSARY.md — short entries, each linking the page that explains it in full
- CONTRIBUTING.md — house rules, if you are adding a page
- Rotation is not encryption ↗ — the sibling page this library grew out of, and the one that draws the line between the two subjects