http-ece is a Python library that implements Encrypted Content Encoding for HTTP, primarily used in contexts like Web Push to secure payload data. It provides functions to encrypt and decrypt arbitrary byte strings using AES-GCM with a derived keying material. The current version is 1.2.1, and the library has an infrequent release cadence, with the most recent update in August 2024, indicating active maintenance.
pip install http-eceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to encrypt and decrypt a simple byte string using `http-ece` for content encoding. It uses randomly generated keys and salts, which must be securely managed and shared in a production environment. The example focuses on `aes128gcm` version for content encryption without Diffie-Hellman key agreement.
Implement robust key management practices suitable for your application's security requirements (e.g., key derivation, secure storage, authenticated key exchange like Web Push's Diffie-Hellman).
Always convert string inputs to bytes using `.encode('utf-8')` before passing them to `encrypt` or `decrypt` functions. Ensure keys and salts are also byte objects.Ensure the `version` string is consistently passed to both `encrypt` and `decrypt` functions. `aes128gcm` is the recommended and most modern version.
Ensure your build/deployment environment has the necessary development tools (`gcc`, `python-dev`, etc.) to compile `cryptography`. Refer to `cryptography`'s official documentation for detailed prerequisites.
Ensure the package is installed using `pip install http-ece`. The correct import statement is `import http_ece`.
Convert string data to bytes using `.encode('utf-8')` before passing it to `http_ece` functions, and decode byte results to strings using `.decode('utf-8')` if necessary. Example: `encrypted_data = http_ece.encrypt(plaintext.encode('utf-8'), ...)`Verify that the encrypted content, salt, and keys (including DH key, authentication secret) used for decryption are exactly the same and correctly derived from what was used during encryption, and that the encrypted payload has not been modified or truncated in transit.