| Crates.io | best-encrypt |
| lib.rs | best-encrypt |
| version | 1.0.0 |
| created_at | 2025-10-13 08:57:17.078473+00 |
| updated_at | 2025-10-13 08:57:17.078473+00 |
| description | A top-level secrets orchestrator. Not just another .env tool โ this one encrypts, locks, and sets you up for secure local and team dev. |
| homepage | https://github.com/kingjethro999/best-encrypt |
| repository | https://github.com/kingjethro999/best-encrypt |
| max_upload_size | |
| id | 1880255 |
| size | 93,847 |
"A top-level secrets orchestrator. Not just another .env tool โ this one encrypts, locks, and sets you up for secure local and team dev."
# Build from source
cd rust
cargo build --release
# Install globally
cargo install --path .
# Or run directly
cargo run -- init
# Initialize vault
encrypt init
# Add secrets
encrypt set API_KEY=your-api-key-here
encrypt set DB_URL=postgres://localhost:5432/mydb
# Lock secrets before committing
encrypt lockup mySuperSecurePassword
# New developer setup
encrypt setup mySuperSecurePassword
use encrypt::{get_secret, set_secret, get_all_secrets};
// Method 1: Auto-unlock with environment variable (Recommended for production)
// Set ENCRYPT_PASSWORD=your-password in your environment
let api_key = get_secret("API_KEY")?;
let db_url = get_secret("DB_URL")?;
// Method 2: Explicit password parameter
use encrypt::sdk::SDK;
let api_key = SDK::get("API_KEY", Some("your-password"))?;
// Method 3: Works when vault is already unlocked
let api_key = SDK::get("API_KEY", None)?;
// Use in your app
let config = Config {
api_key,
database: db_url,
port: std::env::var("PORT").unwrap_or_else(|_| "3000".to_string()),
};
// Set secrets
set_secret("NEW_KEY", "new_value")?;
// Get all secrets
let all_secrets = get_all_secrets()?;
// Set ENCRYPT_PASSWORD environment variable
// Works automatically in any environment
use encrypt::get_secret;
let api_key = get_secret("API_KEY")?;
let db_url = get_secret("DB_URL")?;
use actix_web::{web, App, HttpServer, Result};
use encrypt::get_secret;
async fn index() -> Result<&'static str> {
let api_key = get_secret("API_KEY")?;
// Use api_key in your handler
Ok("Hello world!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(index))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
| 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!) |
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.
encrypt init
Creates:
/.encrypt/
โโโ vault.lock (encrypted storage)
โโโ secrets.enc.json
โโโ .gitignore (ensures raw secrets never get committed)
encrypt lockup mySuperSecurePassword
This:
.encrypt/secrets.enc.jsongit clone your-repo
cd your-repo
encrypt setup mySuperSecurePassword
This:
# Build in development mode
cargo build
# Run tests
cargo test
# Run examples
cargo run --example test_crypto
cargo run --example example
cargo run --example test_auto_converter
cargo run --example production_example
# Run demo
cargo run -- init
cargo run -- setup mypassword
cargo run -- set API_KEY=sk-1234567890abcdef
cargo run -- status
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
# Test encryption/decryption
cargo run --example test_crypto
# Test runtime SDK
cargo run --example example
# Test auto-converter
cargo run --example test_auto_converter
# Test production usage
cargo run --example production_example
Set the ENCRYPT_PASSWORD environment variable in your production environment:
# Docker
ENV ENCRYPT_PASSWORD=your-production-password
# Kubernetes
env:
- name: ENCRYPT_PASSWORD
valueFrom:
secretKeyRef:
name: encrypt-secrets
key: password
# Heroku
heroku config:set ENCRYPT_PASSWORD=your-password
# AWS Lambda
# Set ENCRYPT_PASSWORD in environment variables
// Works automatically with ENCRYPT_PASSWORD environment variable
use encrypt::get_secret;
let api_key = get_secret("API_KEY")?;
let db_url = get_secret("DB_URL")?;
// No need to manually unlock the vault!
use rocket::{get, launch, routes, State};
use encrypt::get_secret;
#[get("/")]
fn index() -> &'static str {
let api_key = get_secret("API_KEY").unwrap();
// Use api_key in your handler
"Hello, world!"
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}
.encrypt/ folder.env files are static and hard to share securelyThis tool solves that problem in a slick, dev-friendly way with Rust's performance and safety guarantees.
MIT