threatflux_hashing/lib.rs
1//! # ThreatFlux Hashing
2//!
3//! A high-performance async file hashing library supporting MD5, SHA256, SHA512, and BLAKE3.
4//!
5//! ## Features
6//!
7//! - Async/await support with tokio
8//! - Concurrent hash calculation
9//! - Configurable buffer sizes and concurrency limits
10//! - Optional serde support
11//! - Zero-copy operations where possible
12//!
13//! ## Quick Start
14//!
15//! ```no_run
16//! use threatflux_hashing::calculate_all_hashes;
17//! use std::path::Path;
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
21//! let hashes = calculate_all_hashes(Path::new("file.bin")).await?;
22//! println!("MD5: {:?}", hashes.md5);
23//! println!("SHA256: {:?}", hashes.sha256);
24//! println!("SHA512: {:?}", hashes.sha512);
25//! println!("BLAKE3: {:?}", hashes.blake3);
26//! Ok(())
27//! }
28//! ```
29//!
30//! ## Custom Configuration
31//!
32//! ```no_run
33//! use threatflux_hashing::{calculate_all_hashes_with_config, HashConfig, HashAlgorithms};
34//! use std::path::Path;
35//!
36//! #[tokio::main]
37//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
38//! let config = HashConfig {
39//! algorithms: HashAlgorithms {
40//! md5: true,
41//! sha256: true,
42//! sha512: false, // Skip SHA512
43//! blake3: true,
44//! },
45//! buffer_size: 16384, // 16KB buffer
46//! max_concurrent_operations: 20,
47//! };
48//!
49//! let hashes = calculate_all_hashes_with_config(Path::new("file.bin"), &config).await?;
50//! Ok(())
51//! }
52//! ```
53
54pub mod error;
55pub mod hasher;
56
57pub use error::{HashError, Result};
58pub use hasher::{
59 calculate_all_hashes, calculate_all_hashes_with_config, calculate_md5, HashAlgorithms,
60 HashConfig, Hashes,
61};
62
63// Re-export tokio for convenience
64pub use tokio;