pyhpke
A Python implementation of HPKE.
What it is and what it does
PyHPKE is a Python library implementing the HPKE standard from RFC 9180, enabling secure message encryption between a sender and recipient using hybrid public-key cryptography. It supports all four HPKE modes (Base, PSK, Auth, AuthPSK) and provides multiple cipher suite combinations across key encapsulation mechanisms (DHKEM variants for P-256, P-384, P-521, X25519, X448), key derivation functions (HKDF-SHA256/384/512), and authenticated encryption algorithms (AES-GCM, ChaCha20Poly1305, Export Only).
The library wraps cryptographic operations from the cryptography package and exposes a straightforward API: create a cipher suite, load or derive keys from JWK or PEM formats, establish sender and recipient contexts, and seal or open messages. It has been tested against RFC 9180 official test vectors but has not undergone formal security audit, making it suitable for non-critical applications or as a reference implementation rather than as a drop-in replacement for audited production cryptography libraries.
Use it for:
- Encrypt messages for a known recipient when you have their public key and need authenticated encryption.
- Implement end-to-end encryption in protocols or applications requiring RFC 9180 compliance.
- Derive cryptographic keys from seed material using standardized key encapsulation and derivation functions.
- Test HPKE cipher suite combinations and modes without external dependencies beyond cryptography.
- Build multi-recipient encryption systems using HPKE's authenticated modes with pre-shared keys.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyHPKE implements HPKE (Hybrid Public Key Encryption) as defined in RFC 9180, providing authenticated encryption with public-key cryptography for sender-recipient message exchange.
Yes, if you need RFC 9180 HPKE for non-critical applications or prototyping. The library is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive MIT license. However, note that it has not been formally audited—do not use it for high-security applications without independent security review.
Install
pyhpke on PyPI
pip
pip install pyhpkeuv
uv add pyhpkepoetry
poetry add pyhpkeInstalling pyhpke
Before you install
Low install friction: pure Python wheel with a single runtime dependency on cryptography. Active maintenance with a release 29 days ago and commits through August 2026.
License in practice
MIT license (permissive) allows free use, modification, and distribution with minimal restrictions, suitable for both open-source and proprietary projects.
Quickstart
from pyhpke import AEADId, CipherSuite, KDFId, KEMId, KEMKey
suite = CipherSuite.new(
KEMId.DHKEM_P256_HKDF_SHA256, KDFId.HKDF_SHA256, AEADId.AES128_GCM
)
enc, sender = suite.create_sender_context(public_key)
ct = sender.seal(b"message")
Requires Python 3.10 or later; recipient must have corresponding private key to decrypt.
Verify before relying
- Whether formal security audit has been completed since the unaudited status noted in the description.
- Real-world performance characteristics compared to alternative HPKE implementations.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — cryptography |
| Maintenance | actively maintained — 29 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 309,516/month — #7,754 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyhpke-0.6.5-py3-none-any.whl
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
py-eccImplements elliptic curve cryptography…
permissive · top 5,000 on PyPI
eciespyEncrypts and decrypts data using Elliptic Curve…
permissive · top 15,000 on PyPI
aes-pkcs5Provides AES encryption and decryption with…
permissive · top 15,000 on PyPI
pycryptodomexPyCryptodomex provides low-level cryptographic…
permissive · top 1,000 on PyPI
xxteaxxtea is a Python extension that implements the…
permissive · top 15,000 on PyPI
jwskateImplements the JOSE family of IETF standards…
permissive · top 5,000 on PyPI
py3rijndaelpy3rijndael provides a pure-Python…
permissive · top 15,000 on PyPI
pyDesPure Python implementation of DES and Triple…
permissive · top 15,000 on PyPI
slip10Implements SLIP-0010 hierarchical deterministic…
permissive · top 15,000 on PyPI