Example project of secret information sharing between Alice and Bob using Diffie-Hellman algorithm
Project description
Alice and Bob information sharing code challenge
Diffie-Hellman coding challenge for secret information exchange using public/private keys
Background
Alice and Bob use the Diffie-Hellman key exchange algorithm to share secret information. Alice and Bob start with prime numbers, pick private keys, generate and share public keys, finally they then generate a shared secret key.
Your code module should take in two prime numbers, p and g and output the value of p and g, the private key a for Alice and b for Bob. Finally your program should print out the Shared Secret key for Alice and Bob.
If your implementation is correct, the Shared Secret keys should match.
Note: This challenge requires you to perform calculations on large numbers. Further information can be found at https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
Code requirements
- Ensure that your code is clean and uses good practice (e.g. error handling) and is commented well.
- Ensure that your code can work cross platform and across different versions of Python.
- Feel free to add as many bells and whistles as you so desired (e.g. Unit Tests)
Running the code
git clone https://github.com/Liam-Deacon/alice_and_bob
cd alice_and_bob
python3 -m alice_and_bob.key_share --help
CLI Example
$ python3 -m alice_and_bob.key_share -p 61 -g 53
Shared secret key: 60
It is also possible to specify the number of bits used for the generated private keys:
$ python3 -m alice_and_bob.key_share -p 88937 -g 104729 --bits=2048
Shared secret key: 39885
Python Example
>>> from alice_and_bob.key_share import main as code
>>> code(p=2, g=3) # only one possibility as primes very small
Shared secret key: 1
>>> code(61, 53)
Shared secret key: 34
>>> code(61, 53)
Shared secret key: 37
>>> code(61, 53)
Shared secret key: 9
>>> code(61, 53)
Shared secret key: 11
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file alice_and_bob-0.0.1.tar.gz
.
File metadata
- Download URL: alice_and_bob-0.0.1.tar.gz
- Upload date:
- Size: 270.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8c6f4f7730d3c90e482d03d190969391d6b4b57fdbb4a1964e6c6b58d32e172 |
|
MD5 | e03d1df5e686c10fb46d5a460d155fe6 |
|
BLAKE2b-256 | e4b77982bb818c6533c62f663b272b0033cc4299385563bfdc13523fbd309d26 |