Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ lockenv

Zero-config .env file encryption. Your secrets, version-controlled and safe.

๐Ÿ‡บ๐Ÿ‡ธ English โ€ข ๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน โ€ข ๐Ÿ‡จ๐Ÿ‡ณ ็ฎ€ไฝ“ไธญๆ–‡ โ€ข ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol

Crates.io License: MIT CI

Installation โ€ข Quick Start โ€ข Commands โ€ข How It Works โ€ข FAQ


The Problem

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 .env files 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 commit and your secrets live in git history forever.

The Solution

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.


๐Ÿ“ฆ Installation

From Cargo (recommended)

cargo install lockenv

From Source

git clone https://github.com/FLURI3/lockenv.git
cd lockenv
cargo install --path .

Pre-built Binaries

Download standalone binaries from GitHub Releases for:

  • Linux (x86_64, aarch64)
  • macOS (Apple Silicon / Intel)
  • Windows (x86_64)

๐Ÿš€ Quick Start

1. Initialize in your project

cd your-project
lockenv init

This will automatically:

  • ๐Ÿ”‘ Generate an encryption key (.lockenv/key)
  • ๐Ÿ“„ Add .env and .lockenv/key to .gitignore
  • ๐Ÿ›ก๏ธ Install a Git pre-commit hook (physically blocks committing unencrypted .env files)
  • ๐Ÿ”’ Encrypt any existing .env file into .env.locked

2. Daily Workflow

# 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 unlock

3. Share Key with Your Team

Share .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 unlock

๐Ÿ“– Commands

lockenv init

Initialize lockenv in the current directory.

lockenv init

lockenv lock [file]

Encrypt .env into .env.locked.

lockenv lock              # Encrypts .env -> .env.locked
lockenv lock .env.staging # Encrypts .env.staging -> .env.staging.locked

lockenv unlock [file]

Decrypt .env.locked into .env.

lockenv unlock                     # Decrypts .env.locked -> .env
lockenv unlock .env.staging.locked # Decrypts .env.staging.locked -> .env.staging

lockenv diff <file_a> <file_b>

Compare 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

lockenv example

Generate a .env.example file automatically with stripped secret values.

lockenv example
lockenv example --file .env --output .env.template

lockenv audit

Scan your entire Git history for leaked .env files committed in the past.

lockenv audit

lockenv edit [file]

Decrypt into memory, open in $EDITOR / Notepad, and re-encrypt automatically upon saving.

lockenv edit
EDITOR=nano lockenv edit

๐Ÿ”ง How It Works

  • 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)

โš”๏ธ Comparison

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

๐Ÿค Contributing

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 test

๐Ÿ“„ License

MIT ยฉ lockenv contributors

About

๐Ÿ›ก๏ธ Zero-config .env file encryption. Your secrets, version-controlled and safe.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages