Skip to main content

py-diffie-hellman

PyPI Code style: black

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

Metadata

Release files for py-diffie-hellman 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-diffie-hellman 1.0.1
File Size Uploaded
py-diffie-hellman-1.0.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-diffie-hellman 1.0.1
File Interpreter ABI Platform
py_diffie_hellman-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / py-diffie-hellman-1.0.1.tar.gz

Download URL py-diffie-hellman-1.0.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
31581f199edd0553ea3c4d8169d721f2deb2e8f9fd5245c33be8e66c2618a38a
BLAKE2b-256 checksum
How to use checksums
29cc185a4feb56f4fd312782d53e8dae1a7fc33d0f38408c57e8c077a1fb726a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / py_diffie_hellman-1.0.1-py3-none-any.whl

Download URL py_diffie_hellman-1.0.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6c8f371b4de3972301ed9e1ebda011c3c7c2039011c5f1ecc7e919468f2e14f
BLAKE2b-256 checksum
How to use checksums
c7f26b88a12985d0d2fe56cb8ed54ba5116198ddfd9a305dd563b0f9ff53ee1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page