🔒

Cryptography

From Caesar's simple substitution to RSA and elliptic-curve key exchange. Interactive visualisations that demystify the mathematics keeping modern communication secure.

4 simulations RSA · ECC · AES Modular arithmetic · Primes

Category Simulations

Open a simulation — it runs right in your browser

Learning Resources

Deep dives into cryptography and security

About Cryptography Simulations

Ciphers, key exchange, hashing, and public-key cryptography — visualised

Cryptography simulations make the mathematics of secure communication tangible and interactive. Caesar and Vigenère cipher visualisers show classical substitution and polyalphabetic encryption letter by letter, making frequency analysis attacks obvious. RSA key-generation animations walk through Euler's totient function, modular exponentiation, and the relationship between key length and factoring difficulty.

Diffie–Hellman key-exchange simulations animate the public/private colour-mixing analogy and then show the actual modular-arithmetic protocol, demonstrating how two parties can agree on a shared secret over an insecure channel. Hash-function collision visualisers demonstrate the avalanche effect: how a one-bit change in input flips roughly half the output bits. These visualisations serve introductory cybersecurity courses and system designers learning where cryptographic primitives should be applied.

Each simulation in this category is built with accuracy and interactivity in mind. The underlying mathematical models are the same ones used in academic research and professional engineering — just made accessible through a web browser. Changing parameters in real time and observing the results is one of the most effective ways to build intuition for complex scientific and engineering concepts.

Key Concepts

Topics and algorithms you'll explore in this category

Interactive ModelReal-time browser simulation with live parameter controls
WebGL / Canvas 2DHardware-accelerated rendering in the browser
Mathematical FoundationDifferential equations and numerical integration
Open SourceMIT-licensed code — inspect, fork, and learn
No Install RequiredRuns directly in Chrome, Firefox, Safari, Edge
Educational FocusBuilt to explain the underlying science clearly

Frequently Asked Questions

Common questions about this simulation category

How does RSA encryption work?
RSA relies on the difficulty of factoring large integers. You choose two primes p and q, compute n = p·q and φ(n) = (p−1)(q−1), then pick a public exponent e coprime to φ(n) and compute private key d = e⁻¹ mod φ(n). Encrypting a message m gives c = mᵉ mod n; decrypting gives m = cᵈ mod n. The RSA simulation steps through every calculation so you can see exactly how the keys are generated and used.
How does Diffie-Hellman key exchange allow two parties to agree on a shared secret?
Alice and Bob agree on a public prime p and generator g. Alice sends gᵃ mod p (keeping a secret); Bob sends gᵇ mod p (keeping b secret). Alice computes (gᵇ)ᵃ mod p; Bob computes (gᵃ)ᵇ mod p — both equal gᵃᵇ mod p, the shared secret. An eavesdropper sees gᵃ mod p and gᵇ mod p but cannot compute gᵃᵇ mod p without solving the discrete logarithm problem. The colour-mixing analogy in the simulation makes this intuitive.
Why is elliptic curve cryptography (ECC) preferred over RSA for modern systems?
ECC provides equivalent security to RSA with much smaller key sizes — a 256-bit ECC key matches a 3072-bit RSA key in security level. This means faster computation, smaller certificates, and less bandwidth. ECC security rests on the elliptic curve discrete logarithm problem: given points P and Q = k·P on a curve, finding the scalar k is computationally infeasible. The simulation visualises point addition geometry on the real-number curve.
How does frequency analysis break classical ciphers?
In the Caesar cipher every letter is shifted by a fixed amount, so the frequency distribution of ciphertext letters mirrors that of plaintext. In English, 'E' is the most common letter (~13%), so the most common ciphertext letter is likely the encryption of 'E'. The Vigenère cipher uses multiple shifts (a key), flattening frequencies — but index-of-coincidence analysis can still recover the key length. The Caesar and Vigenère simulation shows these attacks in real time.

Other Categories