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§
- Digest
Value - Hash
Result - Completed digest values for one hashing run.
- Multi
Hasher - Pipelined
Multi Hasher - Unknown
Algorithm
Enums§
- Algorithm
- Hash
Error - Error returned by high-level reader and file hashing helpers.
- Pipelined
Hash Error
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.