๐ Diffie-Hellman Key Exchange Demo
This is an educational demo. Small numbers are not suitable for real security.
Enter a prime p, a generator g, and both partiesโ private keys (a, b) to see how the Diffie-Hellman key exchange algorithm computes public keys and a shared secret. Confirm for yourself that both sides independently arrive at the same shared secret via different calculation paths.
How to use
- Enter the prime p and generator g.
- Enter Aliceโs and Bobโs private keys (a, b).
- The public keys (A, B) and the matching shared secret computed by each side are shown automatically.
FAQ
What is Diffie-Hellman key exchange?
An algorithm that lets two parties with no prior shared secret establish a common secret key over an insecure channel. It underlies many encrypted protocols, including TLS.
Why do both sides get the same shared secret?
Because of the laws of exponents: (g^a)^b mod p and (g^b)^a mod p are always mathematically equal.
Can I use these small numbers for real security?
No โ this is an educational demo to illustrate the mechanism. Real-world use requires very large primes (2048 bits or more).