2 releases
new 0.1.1 | Feb 14, 2025 |
---|---|
0.1.0 | Feb 6, 2025 |
#1552 in Cryptography
246 downloads per month
12KB
136 lines
simple-encrypt
A simple encryption tool built in Rust. If you need basic symmetric-key encryption with reasonable defaults for your project, without having to wade through the forest of encryption algorithms and parameters, this tool will make your life easier. It uses the AES-GCM-256 scheme, which is considered industry-standard.
Provides both a command-line interface and library for encrypting files and data.
Example use case: You have a configuration file containing secrets like API keys, database passwords, crypto seed phrases, etc. You want to securely use these secrets during local development, and be able to deploy them to remote environments. A good way to do this is encrypt your secrets at rest in all environments, and only decrypt them in-memory in your application. This is especially important in today's world, where AI-powered IDEs are constantly sending your code (and potentially plaintext secrets) to a remote server.
Installation
Command Line Tool
cargo install simple-encrypt
Library
Add to your Cargo.toml
:
[dependencies]
simple-encrypt = "0.1.0"
Quick Start
Command Line
Encrypt a file:
simple-encrypt encrypt --input config.json --output config.json.enc
Decrypt a file:
simple-encrypt decrypt --input config.json.enc --output config.json
In Your Code
use simple_encrypt::{encrypt_bytes, decrypt_bytes};
// Encrypt sensitive configuration
let config = r#"{"api_key": "secret123", "db_password": "dbpass"}"#;
let password = "your-secure-password";
let encrypted = encrypt_bytes(config.as_bytes(), password)?;
// Later, decrypt only when needed
let decrypted = decrypt_bytes(&encrypted, password)?;
let config = String::from_utf8(decrypted)?;
License
MIT - See LICENSE for details
Contributing
Contributions are welcome! Feel free to submit issues and pull requests.
Dependencies
~4–14MB
~114K SLoC