Diffie-Hellman Secret Chat
Python API
About The Project
This project is a tiny, crazy-looking demo of how two people can talk secretly over a totally insecure channel just by doing some smart logical math – the Diffie-Hellman (DH) key exchange.
Once the key is agreed, the messages are “scrambled” with that key, so anyone sniffing the network sees only gibberish.
What this project shows
How two parties (Alice and Bob) generate a shared secret key without ever sending the secret itself.
How that shared secret can be used to encrypt and decrypt messages over a normal TCP connection.
That pure math (modular exponentiation + random numbers) is enough to build a private communication channel.
At a high level:
Alice and Bob agree on public numbers pp and gg.
Each picks a private number (never shared).
Each sends a corresponding public value.
Using the other’s public value and their own private one, both compute the same shared secret key.
That key is then used to XOR‑encrypt chat messages, turning normal text into apparently random symbols.
Anyone watching the traffic sees only encrypted junk, but Alice and Bob see normal text.
© 2025 Framer template by Anton Drukarov







