Secure .env file encryption using OS keychain. Keep secrets encrypted at rest.
Project description
Envcipher
Encrypt .env files using AES-256-GCM with keys stored in your OS keychain. Decrypt on demand for local development without managing separate key files.
Installation
Python
pip install envcipher
Provides both the CLI and Python library.
Rust
cargo install envcipher
CLI only.
From Source
git clone https://github.com/iamprecieee/envcipher
cd envcipher
cargo install --path .
Usage
CLI
envcipher init # Generate key, store in OS keychain
envcipher edit # Decrypt -> edit -> re-encrypt
envcipher lock # Encrypt .env in place
envcipher unlock # Decrypt .env to plaintext
envcipher run -- <cmd> # Run command with decrypted env vars
envcipher status # Show encryption status
Python Library
import envcipher
import os
# Load encrypted .env into os.environ
envcipher.load()
# Access secrets
api_key = os.getenv("API_KEY")
Custom path:
envcipher.load(path="/path/to/.env")
Works with both encrypted and plaintext files.
Team Sharing
# Export key
envcipher export-key
# Output: qQWntX6r7eANxsyKHbkJtuXtzW0Hy5zjJGvDSxMKM9I=
# Import on another machine
envcipher import-key qQWntX6r7eANxsyKHbkJtuXtzW0Hy5zjJGvDSxMKM9I=
Share keys through secure channels only.
Security
| Component | Implementation |
|---|---|
| Encryption | AES-256-GCM, 96-bit random nonces |
| Key Storage | OS keychain (Keychain / Credential Manager / Secret Service) |
| Memory | Keys zeroized on drop |
| Format | ENVCIPHER:v1:<nonce>:<ciphertext> |
Designed for: Protecting secrets from accidental commits, local development encryption at rest, small team key sharing.
Not designed for: Production secret management, zero-trust environments, HSM requirements.
FAQ
Can I manually edit the encrypted file?
No. Use envcipher edit or the unlock-edit-lock workflow. Manual edits corrupt the format.
Can I commit the encrypted .env file?
Yes, but we recommend using .gitignore and sharing via export-key/import-key instead. Committing encrypted files is safe only if your team securely shares the key.
What if I lose my key?
Keys are stored in your OS keychain. If you lose access (e.g., fresh OS install), get a teammate to run export-key.
How do I rotate keys?
Currently manual: decrypt with old key, run init in a fresh directory to generate new key, re-encrypt.
Does it work in CI/CD?
Not recommended. Envcipher is designed for local development. CI runners have ephemeral keychains, and storing the key as a CI secret defeats the purpose. Use native secret management instead (GitHub Secrets, AWS Secrets Manager, etc.).
Can I use this on multiple projects?
Yes. Each project directory gets its own key (hashed by directory path). Moving a project folder requires re-importing the key.
License
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 envcipher-0.1.3.tar.gz.
File metadata
- Download URL: envcipher-0.1.3.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c73b9ad74e735f4399d4a30b98f4e87e5db909c1f35915b65c67d1f366790011
|
|
| MD5 |
4e2ab70d59a92bed603a270727b4c8ab
|
|
| BLAKE2b-256 |
c19927c43da1d867f8c161ccde97d2717164ce68da7707b432db8a9bf995ad08
|
File details
Details for the file envcipher-0.1.3-cp314-cp314-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: envcipher-0.1.3-cp314-cp314-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 554.9 kB
- Tags: CPython 3.14, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fdf4eb1e25cf8f8bf4163b2710ca791a3834030bac54c4bc2c8555906d5e49b
|
|
| MD5 |
10bed04d64419cf6437d4ec0b6fdd329
|
|
| BLAKE2b-256 |
22e3e405da4938d11b51d6edaff34e7fc4d6e3a02f5f44d6de55c817a8600b98
|