| Crates.io | fluxencrypt |
| lib.rs | fluxencrypt |
| version | 0.3.9 |
| created_at | 2025-09-05 23:24:17.850736+00 |
| updated_at | 2025-09-07 18:26:38.956698+00 |
| description | A high-performance, secure encryption SDK for Rust applications |
| homepage | https://github.com/ThreatFlux/fluxencrypt |
| repository | https://github.com/ThreatFlux/fluxencrypt |
| max_upload_size | |
| id | 1826441 |
| size | 257,450 |
A high-performance, secure encryption SDK for Rust applications, providing both hybrid encryption capabilities and streaming data protection with enterprise-grade security features.
Developed for the ThreatFlux Organization
Add FluxEncrypt to your Cargo.toml:
[dependencies]
fluxencrypt = "0.1.3"
# For async support
fluxencrypt-async = "0.1.3"
# For CLI usage
fluxencrypt-cli = "0.1.3"
use fluxencrypt::{Config, HybridCipher};
use fluxencrypt::keys::KeyPair;
// Generate a new key pair (default 4096-bit)
let keypair = KeyPair::generate(4096)?;
// Create cipher with default configuration
let cipher = HybridCipher::new(Config::default());
// Encrypt data
let plaintext = b"Hello, FluxEncrypt!";
let ciphertext = cipher.encrypt(&keypair.public_key(), plaintext)?;
// Decrypt data
let decrypted = cipher.decrypt(&keypair.private_key(), &ciphertext)?;
assert_eq!(plaintext, &decrypted[..]);
use fluxencrypt::stream::FileStreamCipher;
use std::path::Path;
let cipher = FileStreamCipher::new(config);
// Encrypt a file
cipher.encrypt_file(
Path::new("document.pdf"),
Path::new("document.pdf.enc"),
&public_key
)?;
// Decrypt a file
cipher.decrypt_file(
Path::new("document.pdf.enc"),
Path::new("document_restored.pdf"),
&private_key
)?;
use fluxencrypt_async::{AsyncHybridCipher, Config};
let cipher = AsyncHybridCipher::new(Config::default());
// Async encryption
let ciphertext = cipher.encrypt_async(&public_key, data).await?;
// Async decryption
let plaintext = cipher.decrypt_async(&private_key, &ciphertext).await?;
use fluxencrypt::env::EnvSecretProvider;
// Load keys from environment variables
let provider = EnvSecretProvider::new();
let private_key = provider.get_private_key("FLUX_PRIVATE_KEY")?;
let public_key = provider.get_public_key("FLUX_PUBLIC_KEY")?;
FluxEncrypt includes a powerful CLI for file encryption operations:
# Install the CLI
cargo install fluxencrypt-cli
# Generate a new key pair (4096-bit RSA by default)
fluxencrypt-cli keygen --output-dir ./keys
# Generate keys in base64 format
fluxencrypt-cli keygen --output-dir ./keys --base64
# Encrypt a file
fluxencrypt-cli encrypt --key ./keys/fluxencrypt_key.pub --input document.pdf --output document.pdf.enc
# Encrypt string data directly (outputs base64 by default)
fluxencrypt-cli encrypt --key ./keys/fluxencrypt_key.pub --data "Hello, World!"
# Encrypt with raw binary output
fluxencrypt-cli encrypt --key ./keys/fluxencrypt_key.pub --input document.pdf --output document.pdf.enc --raw
# Decrypt a file
fluxencrypt-cli decrypt --key ./keys/fluxencrypt_key.pem --input document.pdf.enc --output document.pdf
# Decrypt base64 string data directly
fluxencrypt-cli decrypt --key ./keys/fluxencrypt_key.pem --data "base64encodeddata..."
# Decrypt raw binary input
fluxencrypt-cli decrypt --key ./keys/fluxencrypt_key.pem --input document.pdf.enc --raw
# Batch encrypt multiple files
fluxencrypt-cli batch-encrypt --key ./keys/fluxencrypt_key.pub --input-dir ./documents --output-dir ./encrypted
# Stream encrypt large files
fluxencrypt-cli stream-encrypt --key ./keys/fluxencrypt_key.pub --input large-file.bin --output large-file.bin.enc
FluxEncrypt provides flexible configuration options:
use fluxencrypt::{Config, CipherSuite, KeyDerivation};
let config = Config::builder()
.cipher_suite(CipherSuite::Aes256Gcm)
.key_derivation(KeyDerivation::Pbkdf2 {
iterations: 100_000,
salt_len: 32,
})
.compression(true)
.memory_limit_mb(256)
.build();
FluxEncrypt is designed for high performance:
Run benchmarks:
cd fluxencrypt && cargo bench
fluxencrypt/
├── fluxencrypt/ # Core library
├── fluxencrypt-cli/ # Command line interface
├── fluxencrypt-async/ # Async support
├── examples/ # Usage examples
├── benches/ # Performance benchmarks
├── tests/ # Integration tests
└── docs/ # Additional documentation
The fluxencrypt/examples/ directory contains comprehensive examples:
basic_encryption.rs - Simple encrypt/decrypt operations with 4096-bit keysfile_encryption.rs - File-based encryption with streamingkey_management.rs - Key generation, storage, and base64 handlingenvironment_config.rs - Environment-based configurationNote: Examples use 2048-bit keys for demonstration purposes. Production use should prefer 4096-bit keys (CLI default).
We welcome contributions! Please see our Contributing Guidelines for details.
# Clone the repository
git clone https://github.com/ThreatFlux/fluxencrypt.git
cd fluxencrypt
# Install development dependencies
cargo install cargo-audit cargo-deny cargo-outdated
# Run tests
cargo test --all
# Run security audit
cargo audit
# Check for license compliance
cargo deny check
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a detailed history of changes.
FluxEncrypt - Secure, Fast, Reliable Encryption for Rust Applications