Afterglowscreensavers

Diffie–Hellman Key Exchange Screensaver

The Diffie–Hellman Key Exchange screensaver demonstrates the real modular-exponentiation math behind Diffie-Hellman, with two sides reaching a matching shared secret live. It is free, runs in your browser, and ESC exits, and uses small teaching-scale numbers, not production-strength cryptography.

Live preview

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Diffie–Hellman Key Exchange screensaver works

The saver picks a real small prime and a base, then generates two random secret exponents, one for each of two labeled sides.

Each side computes its real public value by raising the shared base to its own secret power, modulo the shared prime — genuine modular exponentiation, shown step by step.

The sides then exchange only their public values and each raises the other side's public value to their own secret power, arriving at a real matching shared secret.

The matching secret is confirmed on screen, then a fresh prime, base and pair of secret exponents begin a new exchange.

A worked example

Both sides independently arrive at the exact same final number despite each raising a different public value to their own different secret power — the real mathematical property that makes key exchange work.

Settings & tips

Frequently asked questions

Is this safe to use for real encryption?
No — it uses small, teaching-scale numbers for visual clarity, not the large primes real cryptographic systems require.
Is the underlying math real?
Yes — genuine modular exponentiation and the real Diffie-Hellman shared-secret property, just at a demonstration scale.
Is a key needed?
No — it is a pure local computation.
Is it free?
Yes — free, no download, in your browser.

← All Science & Research screensavers