Skip to main content

Secure .env file encryption using OS keychain. Keep secrets encrypted at rest.

Project description

Envcipher

Crates.io PyPI License: MIT

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 build --release

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

MIT


Contributing | Code of Conduct | Security

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

envcipher-0.1.2.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envcipher-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (478.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file envcipher-0.1.2.tar.gz.

File metadata

  • Download URL: envcipher-0.1.2.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for envcipher-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bb16a1e4ba2e2688423a581b849635084065e9fd528d1d6c335234c96ae38a34
MD5 d9010c3b209ac0a45d5f5b2fc097e78d
BLAKE2b-256 07fe91465c3aa597fbf46a53bc5ef515b981104b182435951947ec59e1e9dc0c

See more details on using hashes here.

File details

Details for the file envcipher-0.1.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for envcipher-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8bdeefbfac3bcfc5c06dbda46c1938a744d43e72a6ca34069c35733f8899c883
MD5 f91232631df02b04d515125dc669051e
BLAKE2b-256 0d79c3ea3f0e3e1457df94eca4683a289162160e594fa1a7a22003549d2df7b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page