EnvEnc - Secure Environment Variable Management
EnvEnc is a Rust crate that helps you securely encrypt and decrypt environment variables using the ChaCha20-Poly1305 or AES256-GCM encryption schemes. Store sensitive information like API keys, database credentials, and other configuration secrets in your .env
file in a secure, encrypted format.
Features
- Encrypt environment variables before storing them.
- Automatically decrypt environment variables when needed.
- Support for secure key and nonce generation.
- Support for multiple encryption algorithms.
Installation
Add envenc
to your Cargo.toml
:
[]
= "0.0.3"
Usage/Examples
Below is an example of how to encrypt, decrypt, and read environment variables using EnvEnc:
use ;
Output
Database URL: postgres://user:password@localhost/db
API Key: super_secret_api_key
Cache Server: redis://localhost:6379
How It Works
- Key and Nonce Generation: The key and nonce are generated using the provided passwords. This ensures that each encryption is securely tied to the passwords.
- Encryption and Storage: Sensitive environment variables are encrypted and stored in the
.env
file. - Decryption: The encrypted variables are decrypted and read back into the runtime environment using the same key and nonce.
Why Use EnvEnc?
- Security: Environment variables are stored in an encrypted format, reducing the risk of exposing sensitive data.
- Ease of Use: Encrypting and decrypting environment variables is as simple as calling a few functions.
- Customization: You can control the passwords used for key and nonce generation, giving you flexibility in how encryption is handled.