ThreatFlux Hashing
A high-performance async file hashing library for Rust, supporting MD5, SHA256, SHA512, and BLAKE3 algorithms with concurrent processing capabilities.
Features
- 🚀 Async/Await Support - Built on tokio for efficient async operations
- ⚡ Concurrent Processing - Calculate multiple hashes in parallel
- 🔧 Configurable - Customize buffer sizes, concurrency limits, and algorithms
- 📦 Selective Hashing - Choose which algorithms to calculate
- 🔄 Zero-Copy Operations - Efficient memory usage
- 📝 Optional Serde Support - Serialize/deserialize hash results
Installation
Add this to your Cargo.toml:
[]
= "1.7.0"
Quick Start
use calculate_all_hashes;
use Path;
async
Advanced Usage
Custom Configuration
use ;
use Path;
async
Single Hash Calculation
use calculate_md5;
use Path;
async
Concurrent File Processing
use calculate_all_hashes;
use JoinSet;
use Path;
async
Performance Tips
- Buffer Size: Larger buffers (16KB-64KB) generally improve performance for large files
- Algorithm Selection: Skip unnecessary algorithms to reduce computation time
- Concurrency: Adjust
max_concurrent_operationsbased on your system's capabilities - BLAKE3: Consider using BLAKE3 for the best performance-to-security ratio
Supported Algorithms
| Algorithm | Hash Length | Performance | Use Case |
|---|---|---|---|
| MD5 | 128 bits | Fast | Legacy compatibility, checksums |
| SHA256 | 256 bits | Moderate | General purpose, secure |
| SHA512 | 512 bits | Slower | High security requirements |
| BLAKE3 | 256 bits | Very Fast | Modern applications |
Error Handling
The library uses custom error types for better error handling:
use ;
use Path;
async
Features
serde(default): Enable serialization/deserialization support
[]
= { = "1.7.0", = false }
License
Licensed under the MIT License. See LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Benchmarks
Run benchmarks with:
Typical performance on modern hardware:
- MD5: ~500 MB/s
- SHA256: ~300 MB/s
- SHA512: ~200 MB/s
- BLAKE3: ~1 GB/s
Performance varies based on file size, system capabilities, and configuration.