Skip to main content

Crate threatflux_hashing

Crate threatflux_hashing 

Source
Expand description

§ThreatFlux Hashing

A high-performance async file hashing library supporting MD5, SHA256, SHA512, and BLAKE3.

§Features

  • Async/await support with tokio
  • Concurrent hash calculation
  • Configurable buffer sizes and concurrency limits
  • Optional serde support
  • Zero-copy operations where possible

§Quick Start

use threatflux_hashing::calculate_all_hashes;
use std::path::Path;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let hashes = calculate_all_hashes(Path::new("file.bin")).await?;
    println!("MD5: {:?}", hashes.md5);
    println!("SHA256: {:?}", hashes.sha256);
    println!("SHA512: {:?}", hashes.sha512);
    println!("BLAKE3: {:?}", hashes.blake3);
    Ok(())
}

§Custom Configuration

use threatflux_hashing::{calculate_all_hashes_with_config, HashConfig, HashAlgorithms};
use std::path::Path;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = HashConfig {
        algorithms: HashAlgorithms {
            md5: true,
            sha256: true,
            sha512: false,  // Skip SHA512
            blake3: true,
        },
        buffer_size: 16384,  // 16KB buffer
        max_concurrent_operations: 20,
    };
     
    let hashes = calculate_all_hashes_with_config(Path::new("file.bin"), &config).await?;
    Ok(())
}

Re-exports§

pub use error::HashError;
pub use error::Result;
pub use hasher::calculate_all_hashes;
pub use hasher::calculate_all_hashes_with_config;
pub use hasher::calculate_md5;
pub use hasher::HashAlgorithms;
pub use hasher::HashConfig;
pub use hasher::Hashes;
pub use tokio;

Modules§

error
hasher