AES-256-GCM envelope encryption (payload, iv, tag) compatible cross-language.
Project description
dil-gcm-envelope
AES-256-GCM Envelope Encryption for Python
Outputs { payload, iv, tag } compatible with JavaScript, Node.js, Dart/Flutter, and other languages.
This package provides simple, secure, interoperable encryption using AES-256-GCM.
It is designed for cross-platform encrypted API communication, secure app-to-server payloads, and lightweight secrets encryption.
Features
- 🔐 AES-256-GCM encryption
- 📦 Returns
{ payload, iv, tag }— same as the JS NPM package - 🔄 Cross-language compatible (Node.js, Python, Flutter/Dart)
- ⚙️ Two key-derivation modes:
- SHA256(password) — deterministic, ideal for interoperability
- PBKDF2-HMAC-SHA256 — stronger security with salt
- 🔧 Encrypts:
- JSON objects
- Strings
- Bytes
- 🧪 Includes automated tests
- 📁 Optional CLI tool for encryption/decryption
- 🛡 Authenticated encryption with AES-GCM (rejects tampered data)
Installation
pip install dil-gcm-envelope
Usage Examples
1️ Basic SHA-256 Key Mode (cross-language)
from dil_gcm_envelope import encrypt, decrypt
import json
password = "my-secret-key"
data = {"message": "Hello World", "n": 123}
encrypted = encrypt(password, data)
print(encrypted)
plaintext_bytes = decrypt(
password,
encrypted["payload"],
encrypted["iv"],
encrypted["tag"]
)
print(json.loads(plaintext_bytes.decode()))
2️ Strong Mode (PBKDF2)
encrypted = encrypt(
"my-password",
"sensitive text",
use_pbkdf2=True,
pbkdf2_iterations=200_000
)
print(encrypted)
Decrypt:
pt = decrypt(
"my-password",
encrypted["payload"],
encrypted["iv"],
encrypted["tag"],
salt_b64=encrypted["salt"],
pbkdf2_iterations=200_000
)
print(pt.decode())
3️ Encrypt Bytes
binary_data = b"\x01\x02\x03ABC123"
enc = encrypt("pw", binary_data)
pt = decrypt("pw", enc["payload"], enc["iv"], enc["tag"])
print(pt)
🧰 CLI Usage
Encrypt:
dil-gcm-envelope encrypt mypass --text "Hello World"
PBKDF2:
dil-gcm-envelope encrypt mypass --text "Top Secret" --pbkdf2
Decrypt:
dil-gcm-envelope decrypt mypass --payload "..." --iv "..." --tag "..." --salt "..."
Cross-Language Compatibility
Compatible with:
| Language | Package |
|---|---|
| Node.js | @dev_innovations_labs/dil-gcm-envelope/node |
| Browser | @dev_innovations_labs/dil-gcm-envelope/browser |
| Flutter/Dart | dil_gcm_envelope.dart (coming soon) |
| Python | dil-gcm-envelope |
Security Notes
- AES-256-GCM provides authenticated encryption
- SHA-256 derivation is deterministic (simple + compatible)
- PBKDF2 recommended for production
- Never reuse IV for same key (library auto-generates IV)
Testing
pytest -q
Build & Publish
python -m build
twine upload dist/*
Use Cases
- Secure mobile → server communication
- Encrypted API payloads
- End-to-end encrypted messaging
- Secure local storage
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dil_gcm_envelope-0.1.1.tar.gz.
File metadata
- Download URL: dil_gcm_envelope-0.1.1.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d12638fd141e55d6389ad1eca1322f027f1b0a59daf7b90b65f203fa8768a49
|
|
| MD5 |
ff82c91d58c6b7b766e1055e908a627b
|
|
| BLAKE2b-256 |
d51f79da325e2847c04bf08d8f172aea08d9109a2cdd93fbf7a9dcf9f8ecd6bb
|
File details
Details for the file dil_gcm_envelope-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dil_gcm_envelope-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8ec101608f506d327d9d6e1d03d08dae7b48164ac66d40602d9a46e80e889ca
|
|
| MD5 |
51d66e154eb37332bc987c06a4fb3a14
|
|
| BLAKE2b-256 |
0e03c24460c75c8a6e01680fb856a6729de1fb6a873d5c3e7aa598337dbd8fd4
|