๐ Encrypt (Rust)
"A top-level secrets orchestrator. Not just another .env tool โ this one encrypts, locks, and sets you up for secure local and team dev."
๐ Quick Start
Installation
# Build from source
# Install globally
# Or run directly
Basic Usage
# Initialize vault
# Add secrets
# Lock secrets before committing
# New developer setup
๐ป In-Code Usage
Rust
use ;
// Method 1: Auto-unlock with environment variable (Recommended for production)
// Set ENCRYPT_PASSWORD=your-password in your environment
let api_key = get_secret?;
let db_url = get_secret?;
// Method 2: Explicit password parameter
use SDK;
let api_key = SDKget?;
// Method 3: Works when vault is already unlocked
let api_key = SDKget?;
// Use in your app
let config = Config ;
// Set secrets
set_secret?;
// Get all secrets
let all_secrets = get_all_secrets?;
Production Usage
// Set ENCRYPT_PASSWORD environment variable
// Works automatically in any environment
use get_secret;
let api_key = get_secret?;
let db_url = get_secret?;
Actix Web Example
use ;
use get_secret;
async
async
๐งช CLI Commands
| Command | Description |
|---|---|
encrypt init |
Create .encrypt vault |
encrypt lockup <password> |
Encrypt and secure secrets with password |
encrypt setup <password> |
Set up secrets on a new machine |
encrypt set KEY=value |
Add/update a key |
encrypt get KEY |
Fetch decrypted value |
encrypt unlock |
Decrypt everything into .env |
encrypt status |
Check if vault is locked, list keys |
encrypt reset |
Remove vault (careful!) |
๐ Triple Encryption Phases
-
Phase 1: AES-256-GCM Encryption Each secret value is encrypted using AES-256-GCM with a randomly generated nonce.
-
Phase 2: Password Hashing (PBKDF2) The user's master password is used to derive an encryption key securely.
-
Phase 3: HMAC Signatures Encrypted secrets are signed with HMAC to prevent tampering.
๐งพ Example Workflow
๐ Initial Setup
Creates:
/.encrypt/
โโโ vault.lock (encrypted storage)
โโโ secrets.enc.json
โโโ .gitignore (ensures raw secrets never get committed)
๐ Lock Secrets Before Commit
This:
- Encrypts all secret values in
.encrypt/secrets.enc.json - Stores an encrypted hash of your password
- Prevents accidental push of plaintext secrets
๐ค New Developer Setup
This:
- Prompts for password
- Decrypts secrets into memory
- Your app works ๐
๐ง Development
# Build in development mode
# Run tests
# Run examples
# Run demo
๐ Project Structure
src/
โโโ lib.rs # Main library and convenience functions
โโโ main.rs # CLI entry point
โโโ cli.rs # CLI interface using clap
โโโ crypto.rs # Triple-layer encryption implementation
โโโ vault.rs # Vault management and file operations
โโโ sdk.rs # Runtime SDK for in-code usage
โโโ error.rs # Error types and handling
examples/
โโโ test_crypto.rs # Crypto tests
โโโ example.rs # Basic usage example
โโโ test_auto_converter.rs # Auto-converter tests
โโโ production_example.rs # Production usage example
.encrypt/ # Encrypted vault directory (created at runtime)
โโโ vault.lock # Vault configuration and password hash
โโโ secrets.enc.json # Encrypted secrets storage
โโโ vault.unlocked # Lock file indicating vault status
๐งช Testing
# Test encryption/decryption
# Test runtime SDK
# Test auto-converter
# Test production usage
๐ก๏ธ Security Features
- Triple-layer encryption for maximum security
- Password-based key derivation using PBKDF2
- HMAC signatures to prevent tampering
- Memory-only decryption (secrets never written to disk when unlocked)
- Git-safe (only encrypted files are committed)
- Zero-copy operations where possible for performance
๐ Production Deployment
Environment Variable Method (Recommended)
Set the ENCRYPT_PASSWORD environment variable in your production environment:
# Docker
# Kubernetes
# Heroku
# AWS Lambda
# Set ENCRYPT_PASSWORD in environment variables
Your Application Code
// Works automatically with ENCRYPT_PASSWORD environment variable
use get_secret;
let api_key = get_secret?;
let db_url = get_secret?;
// No need to manually unlock the vault!
Rocket Example
use ;
use get_secret;
Security Benefits
- โ
Secrets remain encrypted in
.encrypt/folder - โ Only decrypted in memory during runtime
- โ No plaintext secrets ever written to disk
- โ Environment-specific passwords for dev/staging/prod
- โ Zero configuration required in your app code
- โ Memory-safe with Rust's ownership system
๐ Why Encrypt?
.envfiles are static and hard to share securely- GitHub secrets don't help in local development
- Vault tools like HashiCorp are overkill for small projects
- You want an easy way to lock your dev secrets before pushing and onboard teammates easily
This tool solves that problem in a slick, dev-friendly way with Rust's performance and safety guarantees.
๐ License
MIT