Generate a keypair, encrypt a message with the public key, decrypt it with the private one — and then factor the modulus to see exactly what breaks when the key is too small. Every step shows its working.
Signing runs RSA backwards: the private key produces the signature and the public key checks it.
RSA's entire security is that nobody can recover p and q from n. For small n that is simply false — and everything unravels: factor n, recompute φ(n), recompute d, read the message.
Trial division here gives up past about 107. Real attacks use the number field sieve — but the principle is identical, and it is why production RSA moduli are 2048 bits or more. A 2048-bit modulus has roughly 617 decimal digits.
c = m^e mod n m = c^d mod n ed = 1 mod phi(n)
Pick two large primes p and q and multiply them: n = pq. Compute φ(n) = (p−1)(q−1), choose a public exponent e coprime to φ(n), and find d = e−1 mod φ(n) with the extended Euclidean algorithm.
Publish (n, e). Keep d secret — and destroy p and q, because either one hands over d immediately.
Decryption works by Euler's theorem: since ed ≡ 1 (mod φ(n)), we have ed = 1 + kφ(n), so cd = med = m · (mφ(n))k ≡ m · 1k = m.
Not the mathematics — the implementation. The textbook version above is not safe to deploy, for reasons worth knowing:
The tool shows the mechanism — the slides show why it is built that way.
Why does d exist? Why does decryption work? Why is factoring hard when multiplying is easy? One-on-one tutoring answers all three properly, with the number theory built up from the start.