Skip to main content

Crate hashjunkie

Crate hashjunkie 

Source
Expand description

Fast multi-algorithm hashing for files, streams, and byte slices.

HashJunkie computes many standard, cloud, and file-sharing hashes in one streaming pass. The high-level helpers are usually the right API for Rust applications:

use hashjunkie::{Algorithm, hash_bytes};

let result = hash_bytes(b"hello", &[Algorithm::Blake3, Algorithm::Sha256]);
assert_eq!(
    result.standard(Algorithm::Sha256),
    Some("2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")
);

For files and arbitrary std::io::Read sources, use hash_file or hash_reader. These helpers use the same pipelined multi-hash engine as the CLI when several algorithms are requested.

use hashjunkie::{Algorithm, hash_reader};

let reader = Cursor::new(b"hello");
let result = hash_reader(reader, &[Algorithm::CidV1, Algorithm::Blake3])?;
assert!(result.standard(Algorithm::CidV1).unwrap().starts_with("bafk"));

Structs§

DigestValue
HashResult
Completed digest values for one hashing run.
MultiHasher
PipelinedMultiHasher
UnknownAlgorithm

Enums§

Algorithm
HashError
Error returned by high-level reader and file hashing helpers.
PipelinedHashError

Constants§

DEFAULT_CHUNK_SIZE
Default streaming chunk size used by HashJunkie’s high-level reader helpers.

Functions§

base32_lower_no_padding_multibase
base32_upper_no_padding
bytes_to_lower_hex
hash_bytes
Hashes a byte slice with the requested algorithms.
hash_bytes_default
Hashes a byte slice with HashJunkie’s default algorithms.
hash_file
Hashes a file with the requested algorithms.
hash_file_default
Hashes a file with HashJunkie’s default algorithms.
hash_reader
Hashes all bytes read from a reader with the requested algorithms.
hash_reader_default
Hashes all bytes read from a reader with HashJunkie’s default algorithms.