| Crates.io | hashery |
| lib.rs | hashery |
| version | 0.0.4 |
| created_at | 2025-04-05 12:53:37.885472+00 |
| updated_at | 2025-07-24 11:57:57.75452+00 |
| description | A flexible and efficient async file hashing library supporting multiple hash algorithms (MD5, SHA1, SHA2, SHA3, BLAKE2, BLAKE3). |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1622112 |
| size | 26,636 |
A flexible and efficient async file hashing library for Rust, supporting multiple hash algorithms.
Add this to your Cargo.toml:
[dependencies]
hashery = "0.1"
By default, only MD5 is enabled. To use other algorithms, enable the corresponding features:
[dependencies]
hashery = { version = "0.1", features = ["sha2", "blake3"] }
md5 (default) - Enable MD5 hashingsha1 - Enable SHA1 hashingsha2 - Enable SHA256 and SHA512sha3 - Enable SHA3-256blake2 - Enable BLAKE2b and BLAKE2sblake3 - Enable BLAKE3Feature groups:
full - Enable all supported algorithmsmodern - Enable modern algorithms (SHA2 and BLAKE3)use hashery::{Hashery, Algorithm};
#[tokio::main]
async fn main() -> std::io::Result<String> {
// Create a hasher with MD5 algorithm
let hashery = Hashery::builder()
.algorithm(Algorithm::MD5)
.buffer_size(1024 * 1024) // Optional: Set custom buffer size (default: 1MB)
.build();
// Calculate file hash
let hash = hashery.digest("path/to/file").await?;
println!("File hash: {}", hash);
Ok(())
}
You can also hash bytes or strings directly:
let hashery = Hashery::builder().algorithm(Algorithm::SHA256).build();
// Hash a byte slice
env let hash = hashery.digest_bytes(b"hello world").unwrap();
println!("SHA256: {}", hash);
// Hash a string
let hash = hashery.digest_str("hello world").unwrap();
println!("SHA256: {}", hash);
Using different algorithms: