Read this lesson as text
Cryptography Examples
Math for CS · Axiom Academy
Four worked problems covering modular inverses, RSA, Diffie–Hellman, and classical ciphers. Example 1 — Modular Inverse via Extended Euclidean Example 2 — Small RSA Encrypt/Decrypt Example 3 — Diffie–Hellman Shared Key Both arrive at the same value because g^ ab = g^ ba . Example 4 — Affine Cipher (and Caesar as a special case) Setting a = 1 collapses the affine cipher into a pure Caesar cipher . Either is trivially broken by frequency analysis since the alphabet is so small — but they are perfect first examples of how modular inverses make cryptosystems invertible.
This is the written version of the interactive lesson above. See the full Math for CS course.