Skip to content
Tutorials Center
My learning

Topics

Cryptography Tutorial

Learn Cryptography step by step: 40 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Cryptography? Learn what cryptography is for: confidentiality, integrity, authentication and non-repudiation, how threat models work, Kerckhoffs's principle and its limits.
  2. 2 Encoding, Hashing and Encryption Tell encoding, hashing and encryption apart. See why Base64 and hex are not secret, work with bytes in Python and learn which tool fits which job.
  3. 3 Classical Ciphers and Why They Break Build the Caesar, substitution and Vigenere ciphers in Python, then break each one with brute force, frequency analysis and the index of coincidence.
  4. 4 Cryptanalysis and Attack Models Learn what cryptanalysis is and the four classic attack models (ciphertext-only, known-plaintext, chosen-plaintext, chosen-ciphertext), plus brute force and dictionary attacks.

Math Foundations

  1. 5 Modular Arithmetic Learn clock arithmetic, congruence, fast modular exponentiation with pow(a, b, m) and modular inverses with pow(a, -1, m), the math under RSA and Diffie-Hellman.
  2. 6 GCD and the Extended Euclidean Algorithm Compute the greatest common divisor with Euclid's algorithm, find Bezout coefficients with the extended version and use it to build modular inverses by hand.
  3. 7 Primes and Primality Testing Test whether a number is prime with trial division, the Fermat test and Miller-Rabin in Python, then generate random large primes for cryptographic keys.
  4. 8 Euler's Theorem and the Chinese Remainder Theorem Learn Euler's totient, Fermat's little theorem, the Chinese Remainder Theorem and why the discrete logarithm is hard, with live Python you can run and edit.
  5. 9 Randomness, Entropy and Secure Randomness Learn the difference between a PRNG and a CSPRNG, how entropy is measured, why Python's random module is unsafe for keys, and what nonce reuse breaks.

Hashing

  1. 10 Cryptographic Hash Functions Understand what makes a hash function cryptographic: preimage and collision resistance, the avalanche effect, and how to use hashlib with SHA-256, SHA-3 and BLAKE2.
  2. 11 Using Hashes: Integrity, Fingerprints and Commitments See what hashes are good for: verifying file integrity, content-addressed storage, commitment schemes and Merkle trees with inclusion proofs, all in live Python.
  3. 12 Hash Attacks: Collisions, Length Extension and Birthday Run a birthday collision search on a toy hash, learn how MD5 and SHA-1 were broken, and forge a message with a length-extension attack that HMAC prevents.

Symmetric Encryption

  1. 13 XOR and the One-Time Pad Learn how XOR encryption works, why the one-time pad is the only cipher with perfect secrecy, and how reusing a key lets attackers recover messages.
  2. 14 Stream Ciphers and Keystreams Learn how stream ciphers turn a short key into an endless keystream, build ChaCha20 from scratch in Python, and see why reusing a nonce is fatal.
  3. 15 Block Ciphers and AES Understand block ciphers as keyed permutations, compute the real AES S-box in Python, and build a tiny substitution-permutation cipher with avalanche.
  4. 16 Modes of Operation: ECB, CBC, CTR See how ECB leaks patterns, how CBC chains blocks with an IV and padding, how CTR turns a block cipher into a stream cipher, and why all three are malleable.
  5. 17 Authenticated Encryption: GCM and ChaCha20-Poly1305 Learn why encryption alone is not enough, build a toy encrypt-then-MAC AEAD in Python, and watch bit-flipping and padding-oracle attacks fail against it.

Authentication and Keys

  1. 18 MACs and HMAC Learn how message authentication codes prove a message is genuine, build HMAC by hand, use hmac.compare_digest, and see a timing attack and tag forgery.
  2. 19 Password Hashing: PBKDF2, scrypt and Argon2 Why passwords need slow salted hashes, with working Python for salts, rainbow tables, PBKDF2 and scrypt, work factors, peppers and Argon2 guidance.
  3. 20 Key Derivation and Key Management Build HKDF from HMAC, derive many keys from one secret, design a key hierarchy with envelope encryption and rotation, and learn where secrets should live.
  4. 21 Authentication, Multi-Factor and One-Time Passwords Learn the authentication factors, how two-factor authentication works, how HOTP and TOTP one-time passwords are computed with HMAC, and what non-repudiation means.

Public-Key Cryptography

  1. 22 Public-Key Cryptography: The Big Idea Understand asymmetric cryptography: key pairs, one-way trapdoor functions, hybrid encryption, and why a 3072-bit RSA key and a 256-bit curve key are comparable.
  2. 23 Diffie-Hellman Key Exchange Learn how two people agree on a shared secret over an open channel, try it with a small prime, break it by brute force, mount a man-in-the-middle, and run X25519.
  3. 24 RSA from Scratch Build RSA in plain Python: generate primes and keys, encrypt and decrypt, speed up decryption with the CRT, and watch a small modulus fall to a factoring attack.
  4. 25 RSA Padding and Common Pitfalls See why textbook RSA is malleable and deterministic, break small exponents and shared primes in Python, then add OAEP padding and learn why PSS is used for signatures.
  5. 26 Elliptic Curve Cryptography Learn elliptic curve cryptography hands-on: add points on a small curve, multiply by scalars, run ECDH and a toy ECDSA, then try secp256k1 and read about Ed25519.
  6. 27 Digital Signatures Learn how digital signatures prove who wrote a message. Build toy RSA and DSA-style signatures, see why we hash first, and recover a key from a reused nonce.

Protocols and Practice

  1. 28 Certificates and Public-Key Infrastructure Learn how X.509 certificates bind keys to names, how chains of trust reach a root CA, and what revocation and pinning do. Includes a toy CA in Python.
  2. 29 How TLS Works Follow the TLS 1.3 handshake step by step: key shares, certificates, Finished messages, cipher suites and forward secrecy, with a runnable simulation in Python.
  3. 30 Secret Sharing and Zero-Knowledge Basics Split a secret so any k of n shares recover it with Shamir's scheme, then prove you know a key without revealing it using a Schnorr zero-knowledge proof.
  4. 31 Post-Quantum Cryptography Learn what quantum computers threaten, why Shor's algorithm breaks RSA and elliptic curves, and how lattice and hash-based schemes like ML-KEM answer it.
  5. 32 Steganography: Hiding Data in Plain Sight Learn how steganography differs from cryptography, hide a message in the least significant bits of image data, see why it is fragile and how steganalysis detects it.

Projects

  1. 33 Project: Encrypted Vault Build a small encrypted vault: derive keys from a master password with PBKDF2, encrypt then MAC the data, detect tampering, and rotate the password.
  2. 34 Project: A Mini Crypto Library Build a small cryptography library from scratch in Python: modular math, Miller-Rabin primes, RSA keys, padded encryption and signatures, checked by a test suite.
  3. 35 Project: A Tiny Blockchain and Merkle Proofs Build a hash-chained ledger in Python: link blocks with SHA-256, add proof of work, detect tampering and verify Merkle inclusion proofs like a light client.
  4. 36 Project: Break Weak Crypto Play the attacker in a safe lab: crack Caesar and Vigenere with statistics, exploit a reused keystream, factor a tiny RSA key and crack weak password hashes.

Practice and Review

  1. 37 Cryptography Exercises with Solutions Practice cryptography with 15 graded exercises on modular math, hashing, classical and XOR ciphers and RSA. Every solution runs live in your browser.
  2. 38 Common Cryptography Mistakes Learn the cryptography mistakes that break real systems: home-made crypto, ECB mode, hard-coded keys, MD5 passwords, nonce reuse and weak randomness, plus a checklist.
  3. 39 Cryptography Interview Questions Prepare for cryptography interviews: symmetric vs asymmetric, hash vs MAC, why salt, forward secrecy, RSA vs ECC and more, with short answers and runnable code.
  4. 40 Cryptography Cheat Sheet A one-page cryptography cheat sheet: which primitive fits which job, safe parameters, hashlib, hmac and secrets snippets, and a do and don't table.