The Diffie-Hellman key exchange algorithm allows Alice and Bob to securely exchange an encryption key over an insecure communication channel where Eve may be listening. It works by first agreeing on a prime number and primitive root. Then, Alice and Bob each generate a public key by raising the primitive root to the power of their private key and taking the result modulo the prime number. They exchange public keys. Finally, each computes a shared secret key by raising the other's public key to the power of their private key and taking the result modulo the prime number, arriving at the same shared key without having transmitted the private keys.