Zero-config .env file encryption. Your secrets, version-controlled and safe.
๐บ๐ธ English โข ๐ท๐บ ะ ัััะบะธะน โข ๐จ๐ณ ็ฎไฝไธญๆ โข ๐ช๐ธ Espaรฑol
Installation โข Quick Start โข Commands โข How It Works โข FAQ
Every developer has done it:
git add .
git commit -m "quick fix"
git push
# ๐ฑ You just pushed your DATABASE_URL with production passwords to GitHub.env files contain secrets. Putting .env into .gitignore is standard, but:
- Sharing secrets is painful: Sending secrets via Slack/Telegram DMs is insecure and messy.
- Outdated configs: New teammates receive old
.envfiles and waste hours debugging missing keys. - No version history: Who updated
STRIPE_KEY? When? What changed in staging vs prod? - Accidental leaks still happen: One stray
git commitand your secrets live in git history forever.
lockenv encrypts your .env files using modern age cryptography so you can safely commit them to git alongside your code.
lockenv init # One command to generate key, set up .gitignore & pre-commit hook
lockenv lock # Encrypt .env โ .env.locked (safe to commit to git)
lockenv unlock # Decrypt .env.locked โ .env (after git pull)No cloud account. No SaaS subscription. No GPG complexity. Just simple, offline encryption.
cargo install lockenvgit clone https://github.com/FLURI3/lockenv.git
cd lockenv
cargo install --path .Download standalone binaries from GitHub Releases for:
- Linux (x86_64, aarch64)
- macOS (Apple Silicon / Intel)
- Windows (x86_64)
cd your-project
lockenv initThis will automatically:
- ๐ Generate an encryption key (
.lockenv/key) - ๐ Add
.envand.lockenv/keyto.gitignore - ๐ก๏ธ Install a Git
pre-commithook (physically blocks committing unencrypted.envfiles) - ๐ Encrypt any existing
.envfile into.env.locked
# After modifying secrets in .env:
lockenv lock
# Commit the encrypted file safely:
git add .env.locked
git commit -m "update staging credentials"
git push
# Teammates pull and unlock:
git pull
lockenv unlockShare .lockenv/key once through a secure channel (1Password, Bitwarden, encrypted message):
# Team member clones the repo and adds key:
git clone <repo>
echo "PASTE_KEY_HERE" > .lockenv/key
lockenv unlockInitialize lockenv in the current directory.
lockenv initEncrypt .env into .env.locked.
lockenv lock # Encrypts .env -> .env.locked
lockenv lock .env.staging # Encrypts .env.staging -> .env.staging.lockedDecrypt .env.locked into .env.
lockenv unlock # Decrypts .env.locked -> .env
lockenv unlock .env.staging.locked # Decrypts .env.staging.locked -> .env.stagingCompare keys between two environment files without leaking secrets.
lockenv diff .env .env.staging Comparing .env and .env.staging
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
~ API_KEY (changed value)
~ DATABASE_URL (changed value)
- DEBUG (only in .env)
= PORT (same value)
+ REDIS_URL (only in .env.staging)
โน Summary: 1 unchanged, 2 changed, 1 added, 1 removed
Generate a .env.example file automatically with stripped secret values.
lockenv example
lockenv example --file .env --output .env.templateScan your entire Git history for leaked .env files committed in the past.
lockenv auditDecrypt into memory, open in $EDITOR / Notepad, and re-encrypt automatically upon saving.
lockenv edit
EDITOR=nano lockenv edit- Cryptography: Uses the age encryption format (X25519, ChaCha20-Poly1305).
- Format: ASCII Armor (
-----BEGIN AGE ENCRYPTED FILE-----) for clean Git text diffs. - Git Guardian: Pre-commit hook prevents human error before commits happen.
your-project/
โโโ .env โ Plaintext secrets (Ignored by Git)
โโโ .env.locked โ Encrypted secrets (Committed to Git)
โโโ .env.example โ Template file (Committed to Git)
โโโ .lockenv/
โโโ config.toml โ Settings (Committed to Git)
โโโ key โ Encryption key (Ignored by Git)
| Feature | lockenv | git-crypt | SOPS | HashiCorp Vault |
|---|---|---|---|---|
| Zero-Config Setup | โ
lockenv init |
โ GPG required | โ Cloud KMS / Age setup | โ Server setup |
Tailored for .env |
โ Built-in | โ Generic | โ Generic | โ API-based |
| Automatic Git Hook | โ Automatic | โ Manual | โ Manual | โ N/A |
| Env Key Diffing | โ
lockenv diff |
โ No | โ No | โ No |
| Template Generator | โ
lockenv example |
โ No | โ No | โ No |
| Single Binary | โ Rust (No runtime) | โ Needs GPG | โ Needs KMS / CLI | โ Daemon / Client |
Contributions are welcome! Feel free to open an Issue or submit a Pull Request.
git clone https://github.com/FLURI3/lockenv.git
cd lockenv
cargo testMIT ยฉ lockenv contributors