Env-Sync
Encrypted environment variables synchronization tool with database support.
Installation
Install the Env-Sync package with your preferred package manager:
Quick Start
Features
Encryption and Security
Securely encrypts sensitive environment variables using AES-256
Database Support
Stores and synchronizes environment variables in MongoDB database
Easy Integration
Automatically updates the .env file when starting your application
Key Management
Encryption key can be stored in configuration file or environment variable
Usage Guide
CLI Tool
Env-Sync provides a command line interface (CLI):
Configuration Methods
Programmatic Usage
Technical Details
Encryption Mechanism
Encryption key is processed with SHA-256 (creates a 32-byte key)
A random Initialization Vector (IV) is created for each value
IV and encrypted value are stored together
During decryption, the same key and IV are used to obtain the original value
Database Schema
Data stored in MongoDB has the following structure:
Operation Logic
When the CLI tool is run, it fetches encrypted values from the database
Values are made readable through decryption
The existing .env file is read and merged with values from the database
The updated .env file is saved
The requested command (npm start, bun run dev, etc.) is executed
Security Measures
Secret Key
Keep your encryption key secure, as all values can be decrypted with it
Git Security
Add your .env file and configuration files containing secret keys to your .gitignore file
Production
Use a different secret key in production environment
Troubleshooting
The CLI output provides detailed information when you encounter issues. Most common errors:
- Cannot connect to the database
- Incorrect encryption key usage
.envfile write permissions