Diffie-Hellman Visual

EDUCATIONAL DEMONSTRATION - See how Alice and Bob establish a shared secret over an insecure channel using public-private key pairs. Uses small numbers for clarity.

Privacy: this tool processes your data entirely in your browser. Nothing you paste or type is sent to the server.

A prime number (small for demonstration).

A generator modulo p.

Alice secret number.

Bob secret number.

Result

Enter your values and press Calculate — the result appears here.

Worked examples

Classic example

  • prime = 23
  • generator = 5
  • privateA = 6
  • privateB = 15

Result: Both compute shared secret = 2.

Frequently asked questions

How does DH prevent eavesdropping?

An eavesdropper sees g^a mod p and g^b mod p but cannot compute g^(ab) mod p without solving the discrete logarithm problem.

Why is this "educational only"?

Real-world DH uses 2048+ bit primes. Small numbers can be factored instantly. Also, vanilla DH is vulnerable to man-in-the-middle attacks without authentication.

Copied!