Python implementation of the Diffie-Hellman key exchange protocol
Project description
py-diffie-hellman
Python implementation of the Diffie-Hellman key exchange protocol.
Supports RFC 3526 MODP Groups 5, 14, 15, 16, 17, 18 (1536 to 8192 bit) and RFC 2409 Groups 1 and 2 (768 and 1024 bit). The default group is 14 (2048-bit).
The key length in bits may be supplied to the constructor, defaults to 540-bit.
Example
Encryption
from diffiehellman import DiffieHellman
# automatically generate two key pairs
dh1 = DiffieHellman(group=14, key_bits=540)
dh2 = DiffieHellman(group=14, key_bits=540)
# get both public keys
dh1_public = dh1.get_public_key()
dh2_public = dh2.get_public_key()
# generate shared key based on the other side's public key
dh1_shared = dh1.generate_shared_key(dh2_public)
dh2_shared = dh2.generate_shared_key(dh1_public)
# the shared keys should be equal
assert dh1_shared == dh2_shared
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
Built Distribution
Close
Hashes for py_diffie_hellman-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6c8f371b4de3972301ed9e1ebda011c3c7c2039011c5f1ecc7e919468f2e14f |
|
MD5 | 97eb55d513118dd3ffe9ce01405d2090 |
|
BLAKE2b-256 | c7f26b88a12985d0d2fe56cb8ed54ba5116198ddfd9a305dd563b0f9ff53ee1d |