Crypto Lab

Key exchange

Diffie-Hellman Demo

Shows how two parties derive the same shared secret over a public channel.

Key exchange

Playground

Change inputs and inspect the transformation

Both sides combine public parameters with private exponents under modular arithmetic.

Output

Shared secret

2

Bob computes

2

Steps

Transformation trace

  1. Public parameters

    p = 23, g = 5 => shared openly

    Everyone can know the prime modulus and generator.

  2. Alice public value

    5^6 mod 23 => 8

    Alice keeps her exponent private and sends this public value.

  3. Bob public value

    5^15 mod 23 => 19

    Bob keeps his exponent private and sends this public value.

  4. Shared secret

    19^6 mod 23 = 8^15 mod 23 => 2 = 2

    Both sides arrive at the same value without sending it directly.