Skip to main content

Python implementation of the Diffie-Hellman key exchange protocol

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-diffie-hellman-1.0.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

py_diffie_hellman-1.0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file py-diffie-hellman-1.0.1.tar.gz.

File metadata

  • Download URL: py-diffie-hellman-1.0.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for py-diffie-hellman-1.0.1.tar.gz
Algorithm Hash digest
SHA256 31581f199edd0553ea3c4d8169d721f2deb2e8f9fd5245c33be8e66c2618a38a
MD5 166145c2f5dfdc86c7c5136ce9941200
BLAKE2b-256 29cc185a4feb56f4fd312782d53e8dae1a7fc33d0f38408c57e8c077a1fb726a

See more details on using hashes here.

File details

Details for the file py_diffie_hellman-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_diffie_hellman-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for py_diffie_hellman-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6c8f371b4de3972301ed9e1ebda011c3c7c2039011c5f1ecc7e919468f2e14f
MD5 97eb55d513118dd3ffe9ce01405d2090
BLAKE2b-256 c7f26b88a12985d0d2fe56cb8ed54ba5116198ddfd9a305dd563b0f9ff53ee1d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page