A secure CLI tool for encrypting, decrypting, shredding, and rotating secrets files using strong symmetric encryption.
Project description
ENVLock
A secure CLI tool for encrypting, decrypting, shredding, and rotating secrets files (e.g., .env) using strong symmetric encryption (Fernet/AES).
Features
- Encrypt (
lock) and decrypt (unlock) files with a 256-bit key - Key can be provided as hex, base64, or via the
ENVLOCK_ENCRYPTION_KEYenvironment variable - Secure file shredding (overwriting and deleting original file)
- Key rotation (
renew) for re-encrypting with a new key - Short and long CLI options for all commands
Installation
Requires Python 3.8+ and the cryptography and click packages:
pip install cryptography click
Usage
Lock a file (encrypt)
envlock lock [-f FILE] [-k KEY] [-h] [-s]
-f, --file: File to lock (default:.env)-k, --key: Encryption key (hex or base64). If omitted, usesENVLOCK_ENCRYPTION_KEYor generates a new key.-h, --hide-key: Hide generated key output (default: show)-s, --shred: Securely delete original file after locking
Example:
envlock lock -f .env -s
Unlock a file (decrypt)
envlock unlock [-f FILE] -k KEY
-f, --file: File to unlock (default:.env.locked)-k, --key: Encryption key (hex or base64, required)
Example:
envlock unlock -f .env.locked -k <key>
Renew (rotate) encryption key
envlock renew [-f FILE] --old-key OLDKEY [--new-key NEWKEY] [-h]
-f, --file: File to renew (default:.env.locked)--old-key: Current encryption key (hex or base64, required)--new-key: New encryption key (hex or base64, optional; if omitted, a new key is generated)-h, --hide-key: Hide generated new key output (default: show)
Example:
envlock renew --old-key <oldkey>
Key Management
- Keys are 32 bytes (64 hex chars or 32 bytes base64)
- Store keys securely (never in your repo)
- You can use the
ENVLOCK_ENCRYPTION_KEYenvironment variable for automation
Security Notes
- The encrypted file can be public; only the key must remain secret
- Never print or log the key in CI/CD logs
- Use secure deletion (
--shred) for sensitive files - Rotate keys regularly and after any suspected compromise
Shell Completion
envlock supports shell completion for bash, zsh, and fish. To enable it, run:
eval "$(_ENVLOCK_COMPLETE=source_bash envlock)" # for bash
eval "$(_ENVLOCK_COMPLETE=source_zsh envlock)" # for zsh
eval "$(_ENVLOCK_COMPLETE=source_fish envlock)" # for fish
Add the appropriate line to your shell profile to enable completion permanently.
Alternative Installation Methods
macOS/Linux
You can create a Homebrew formula for envlock or use pipx:
pipx install envlock
Windows
Install with pip or pipx:
pip install envlock
# or
pipx install envlock
Troubleshooting
- Upload to PyPI/TestPyPI fails with 400 Bad Request:
- Ensure your version is unique and not already uploaded.
- Check your
pyproject.tomlfor required fields. - Delete the
dist/directory before building.
- Key errors:
- Make sure your key is 32 bytes (64 hex chars or 32 bytes base64).
- If using ENVLOCK_ENCRYPTION_KEY, ensure it is set in your environment.
- Permission errors:
- Run the CLI with appropriate permissions for file access.
FAQ
Q: Can I use envlock for files other than .env?
A: Yes, you can lock/unlock any file by specifying the -f option.
Q: Is the encrypted file safe to store in version control? A: Yes, as long as you keep the key secret.
Q: How do I rotate my encryption key?
A: Use the renew command with --old-key and optionally --new-key.
Q: How do I securely delete the original file?
A: Use the --shred option with the lock command.
License
MIT
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 envlock-1.0.0.tar.gz.
File metadata
- Download URL: envlock-1.0.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22688d48674fb419f17506d554ec4e6c81cfd0357e9d2d831474e10c45a343a8
|
|
| MD5 |
b2cff202931dcaba7cd70f680da12a6f
|
|
| BLAKE2b-256 |
f226fc2f45c51c19c4f73e0b4515191670bc6efd59ca8cade4d6befd5b4a108a
|
Provenance
The following attestation bundles were made for envlock-1.0.0.tar.gz:
Publisher:
publish.yml on nikhiljohn10/envlock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
envlock-1.0.0.tar.gz -
Subject digest:
22688d48674fb419f17506d554ec4e6c81cfd0357e9d2d831474e10c45a343a8 - Sigstore transparency entry: 252245385
- Sigstore integration time:
-
Permalink:
nikhiljohn10/envlock@7494056b23655c27b0e5fb18ecb80ca0335e0c6d -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/nikhiljohn10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7494056b23655c27b0e5fb18ecb80ca0335e0c6d -
Trigger Event:
push
-
Statement type:
File details
Details for the file envlock-1.0.0-py3-none-any.whl.
File metadata
- Download URL: envlock-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d175d14bacb0b8079989ea620939f1a2390627eb3159efe949e8cbddc2c28cf9
|
|
| MD5 |
4b25336c53c0254ab6d15c95da450bb7
|
|
| BLAKE2b-256 |
e1f0152ec374495144fdfbe917c981a29bb59171993784a317f048adfee52e7f
|
Provenance
The following attestation bundles were made for envlock-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on nikhiljohn10/envlock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
envlock-1.0.0-py3-none-any.whl -
Subject digest:
d175d14bacb0b8079989ea620939f1a2390627eb3159efe949e8cbddc2c28cf9 - Sigstore transparency entry: 252245411
- Sigstore integration time:
-
Permalink:
nikhiljohn10/envlock@7494056b23655c27b0e5fb18ecb80ca0335e0c6d -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/nikhiljohn10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7494056b23655c27b0e5fb18ecb80ca0335e0c6d -
Trigger Event:
push
-
Statement type: