# Diffie-Hellman, ElGamal and RSA posted April 2014

I'm in holidays for a week, easter I think, anyway, I didn't know what to do so I coded the **Diffie-Hellman handshake**, the **ElGamal cryptosystem** and the **RSA cryptosystem** in **python**.

You can check the code on github here: github.com/mimoo/crypto_studies

Check the `tests.py`

file to see how the classes are used. Here's an extract:

```
"""Testing Diffie Hellman
"""
# 1. BOB
bob = DiffieHellman()
# G and g are generated automatically
print("G is a group mod %i and of order %i, and the generator g is %i" % (bob.G[0], bob.G[1], bob.g))
# We generate a secret and a public key
bob.generate_secret()
bob.generate_public()
# 2. ALICE
# We already know G and g
alice = DiffieHellman(bob.G, bob.g)
# We generate the secret key and the public key
alice.generate_secret()
alice.generate_public()
# 3. WE CREATE THE SHARED KEY
bob.generate_sharedkey(alice.publickey)
alice.generate_sharedkey(bob.publickey)
# Bob and Alice now have the same _sharedkey and the same public (G, g)
```

As the `README`

says, it might be oversimplified and not totally correct. I mostly did that to do something in Python and also try to memorize how those systems work.

I've also done a lot of **Unity** this week-end. And also a bit of **WxPython** but I don't really like it. I think I should focus on **QT** and **C++**.