A tool to manage encrypted environment variables.
Project description
EnvVault
EnvVault is a Python package for encrypting and managing .env files, similar to Rails Credentials. It allows you to securely store sensitive information (such as API keys, database passwords, etc.) and decrypt and use this information at runtime.
Features
- Encrypt
.envfiles: Encrypt plaintext.envfiles into.env.encfiles. - Decrypt
.env.encfiles: Decrypt.env.encfiles at runtime and load environment variables. - Multi-environment support: Create separate encrypted files for different environments (e.g.,
development,production). - CLI tool: Provides a command-line interface for managing encrypted files.
- Integration with
pydantic_settings: Supports managing decrypted environment variables usingpydantic_settings.
Installation
Install using Poetry:
poetry add envvault
# Or install using pip:
pip install envvault
Usage
1. Initialize
Initialize the master key and an empty .env.enc file:
envvault init --env development
This will generate the following files:
master.key: The master key used for encryption and decryption..env.development.enc: An empty encrypted file.
2. Edit Encrypted File
Edit the .env.enc file using your default editor:
envvault edit --env development
The editor will open a temporary file. After editing, the content will be re-encrypted and saved to .env.development.enc.
3. View Decrypted Environment Variables
Decrypt and view the contents of the .env.enc file:
envvault view --env development
4. Use in Code
Load decrypted environment variables in your code:
from envvault.settings import Settings
# Load configuration for the development environment
settings = Settings.from_credentials(env_name="development")
print("API Key:", settings.API_KEY)
print("Database URL:", settings.DATABASE_URL)
Examples
Initialize and Edit Encrypted File
-
Initialize:
envvault init --env development
-
Edit:
envvault edit --env development
Enter the following content in the editor:
API_KEY=your_api_key_here DATABASE_URL=your_database_url_here
-
View:
envvault view --env development
Output:
API_KEY=your_api_key_here DATABASE_URL=your_database_url_here
Use in Code
from envvault.settings import Settings
# Load configuration for the development environment
settings = Settings.from_credentials(env_name="development")
print("API Key:", settings.API_KEY)
print("Database URL:", settings.DATABASE_URL)
Configuration
Default Editor
You can set the default editor using the EDITOR environment variable. For example:
export EDITOR=code # Use VS Code
export EDITOR=nano # Use Nano
export EDITOR=vim # Use Vim
Multi-Environment Support
EnvVault supports creating separate encrypted files for different environments. For example:
.env.development.enc: Development environment..env.production.enc: Production environment.
Specify the environment name using the --env parameter in CLI commands.
Contributing
Issues and Pull Requests are welcome!
License
MIT
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
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 envvault-0.1.1.tar.gz.
File metadata
- Download URL: envvault-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.7 Darwin/24.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd91738188d3d964ccd58ca0b13d5a2778ec96cdac13f708eb0dfee28d8a61cd
|
|
| MD5 |
c30504486746e5f4dcd23539d5e912f3
|
|
| BLAKE2b-256 |
4d445b412a6d816b318566dd209b6fea011ac902319fffbcce2c7d269348b641
|
File details
Details for the file envvault-0.1.1-py3-none-any.whl.
File metadata
- Download URL: envvault-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.7 Darwin/24.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
266224e607c6c767f1e492063091472a2491a955b6a052b37fbc4c5cdb033262
|
|
| MD5 |
e9a974f4169055b7a41bec0e85ac17eb
|
|
| BLAKE2b-256 |
425e16c0dd24b737fdc1ba0c7b7332148f136a98b935307a860b291374214729
|