Core encryption utilities for python envencrypt
Project description
envencrypt-core
Core encryption utilities for Python envencrypt - A collection of high-performance, secure encryption modules built with Rust and exposed to Python via PyO3.
Overview
envencrypt-core provides platform-specific encryption capabilities for securing sensitive data like environment variables, passwords, and configuration files. The library leverages native OS security features to provide robust encryption with minimal performance overhead.
[!NOTE] Currently only the windows DPAPI is implemented.
Features
- Windows platform encryption: Support for Windows DPAPI
- High performance: Rust-based implementation for maximum speed and safety
- Secure by default: Uses OS-native security APIs and best practices
- Python integration: Seamless Python bindings with proper type hints
- Zero-copy operations: Efficient memory handling for large data
Modules
DPAPI (Windows)
Windows Data Protection API integration for secure data encryption:
- User scope encryption: Data encrypted for current user account
- Machine scope encryption: Data encrypted for the machine
- Optional entropy: Additional security layer with custom entropy
- Automatic key management: No manual key handling required
Installation
pip install envencrypt-core
Note: Platform-specific modules are automatically installed based on your operating system.
Quick Start
DPAPI (Windows only)
from envencrypt_core.dpapi import dpapi_protect, dpapi_unprotect
# Basic encryption (user scope)
data = b"sensitive information"
encrypted = dpapi_protect(data)
decrypted = dpapi_unprotect(encrypted)
# With custom entropy for additional security
entropy = b"custom-entropy-string"
encrypted = dpapi_protect(data, entropy)
decrypted = dpapi_unprotect(encrypted, entropy)
# Machine scope (requires admin privileges)
encrypted = dpapi_protect(data, machine_scope=True)
decrypted = dpapi_unprotect(encrypted)
API Reference
DPAPI Functions
dpapi_protect(data, optional_entropy=None, machine_scope=False)
Encrypts data using Windows DPAPI.
Parameters:
data(bytes): Data to encryptoptional_entropy(bytes, optional): Additional entropy for encryptionmachine_scope(bool, optional): Use machine scope instead of user scope
Returns: bytes - Encrypted data
dpapi_unprotect(data, optional_entropy=None)
Decrypts data encrypted with DPAPI.
Parameters:
data(bytes): Encrypted data to decryptoptional_entropy(bytes, optional): Entropy used during encryption
Returns: bytes - Decrypted data
Security Considerations
- DPAPI: Data is tied to the user account or machine. Encrypted data cannot be decrypted by different users or on different machines (unless using machine scope).
- Entropy: When using DPAPI with custom entropy, ensure the entropy is stored securely and separately from the encrypted data.
Development
Prerequisites
- Rust 1.70+
- Python 3.11+
- Platform-specific development tools (Windows SDK, Linux development packages)
Building from Source
# Clone the repository
git clone <repository-url>
cd envencrypt-core
# Build all modules
./build_all.ps1
# Or build individual modules
cd crates/dpapi && cargo build --release
cd crates/keyring && cargo build --release
Testing
# Run Rust tests
cargo test
# Run Python integration tests
python -m pytest tests/
Platform Support
| Platform | DPAPI | Keyring |
|---|---|---|
| Windows | ✅ | 🚧 |
| macOS | ❌ | 🚧 |
| Linux | ❌ | 🚧 |
License
This project is licensed under the GPL-3.0-or-later License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please ensure all tests pass and follow the existing code style.
Authors
- Dyve - dev@dyve.ch
- Igor Petrovic - 758832+igorovic@users.noreply.github.com
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 Distributions
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 envencrypt_core-0.2.0.tar.gz.
File metadata
- Download URL: envencrypt_core-0.2.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f985ae7e7dd7f19e883666712c69674a5c89f641cb01a23f181bb5e1cf277ba
|
|
| MD5 |
469525cf3d69eb039bebe4966181ade4
|
|
| BLAKE2b-256 |
198451367ae5c14081beac4a3525d57cffbe190e8ad0ea31f3b5c6de122ad05c
|
File details
Details for the file envencrypt_core-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: envencrypt_core-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 114.8 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b69b665932996a5da41e0851d6298470ec6499938e5456baa998ba8daafa0ba3
|
|
| MD5 |
56da9ef6156a45ca52ac109a3331c1e0
|
|
| BLAKE2b-256 |
c3b95e4bfe84e212773aaf4657c5edfafa3ec2e4f8ea928925e40ca0f6d77281
|
File details
Details for the file envencrypt_core-0.2.0-cp39-abi3-win32.whl.
File metadata
- Download URL: envencrypt_core-0.2.0-cp39-abi3-win32.whl
- Upload date:
- Size: 108.8 kB
- Tags: CPython 3.9+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d594c8cf860deb29f75bd612b2e6dfe6cba000158102d0b8b9ea9bf8829b7ea
|
|
| MD5 |
05b24705526c3c2ed30dace7c91cbf64
|
|
| BLAKE2b-256 |
94870d61df5d2c64de2081d12752a857ac016e6051f3ba32a31a9eb248169e82
|