EENV
Encrypted Env Manager
EENV keeps secrets safe and dev-friendly:
- Encrypts
.env* → .env*.encwith XChaCha20-Poly1305 (single shared key). - De/encrypts on demand so teammates can pull encrypted files and decrypt locally with the same key.
- Blocks secret leaks by refusing commits that include raw
.env*files. - Generates
.env*.exampleskeletons automatically. - Manages a pre-commit hook so all of the above runs for you.
Install
# from crates.io
# from source (local dev)
# from Git (before publishing)
The binary is
eenv.
Quick Setup
In a repo that has .env files:
# one-time setup: installs hook, fixes .gitignore, ensures config, generates examples, encrypts
First time on a new machine (only .enc files exist), run eenv init and enter the shared key to decrypt.
Commands (overview)
eenv init
- Prints repo state.
- If
.env*.encexist:- With a valid
eenv.config.json, decrypts to plaintext without clobbering existing files. - If config is missing/invalid, prompts for key and bootstraps it.
- With a valid
- If real
.env*exist:- Generates
.env*.example. - Aligns
.gitignore(keeps examples &.enc, ignores real.env*andeenv.config.json). - Encrypts
.env* → .env*.enc.
- Generates
eenv pre-commit [--write]
- Always blocks staging raw
.env*(except*.example/*.enc). - With
--write:- Generates/updates
.env*.example. - Fixes
.gitignoreif needed. - Ensures
eenv.config.jsonexists/valid. - Encrypts
.env* → .env*.encandgit adds produced artifacts.
- Generates/updates
eenv hook install [--force]
- Installs the pre-commit hook (respects
git config core.hooksPath). --forcewill overwrite a non-EENV hook (backs it up first).
eenv hook uninstall [--force]
- Removes the EENV pre-commit hook.
--forceremoves the hook file even if it didn’t come from EENV.
(There’s also a small demo greet command.)
Typical Flows
New project with plaintext env files
Teammate / CI on a fresh clone
# now you have decrypted .env files locally (without clobbering existing ones)
Day-to-day committing
- Stage your changes as usual.
- The pre-commit hook runs:
- Refuses raw
.env*in the index. - If you want auto-fixes and fresh encryption:
- Run
eenv pre-commit --write(or rely on the hook if you configured it to call with--write).
- Run
- Refuses raw
Key & Security Notes
- The shared key lives in
eenv.config.json(ignored by git).
A stable 32-byte key is derived using BLAKE3; files are encrypted with XChaCha20-Poly1305 using a random per-file nonce. - To rotate the key: update
eenv.config.jsonwith the new key and runeenv pre-commit --write.
Uninstall
# remove the hook
(This does not delete your .enc files or config.)
FAQ
-
Git GUI/clients (e.g., GitHub Desktop)?
If they respect Git hooks (most do when the hook files are in the repo’s hooks path), the EENV pre-commit will run. EENV installs into whatevergit rev-parse --git-path hooksreturns, so it works with customcore.hooksPathtoo. -
“unrecognized subcommand 'PreCommit'”
Use kebab-case:eenv pre-commit(Clap mapsPreCommit→pre-commit).