Cryptography & Security
Advanced

Diffie–Hellman Shared Secret

Two parties derive the same secret over a public channel.

Formula

s=Bamodps = B^a \bmod p

Variables

sShared secret
BOther party's public value
aYour private key
pPrime modulus

Example

B=8, a=15, p=23: s = 8^15 mod 23 = 2

Did You Know?

Diffie–Hellman (1976) was the first published way for strangers to agree a secret in public — the birth of modern crypto.

Share this formula