| Crates.io | sha2_hasher |
| lib.rs | sha2_hasher |
| version | 0.3.2 |
| created_at | 2026-01-18 03:37:46.119342+00 |
| updated_at | 2026-01-18 06:34:55.377887+00 |
| description | A trait extension for hashing files with SHA-2 algorithms |
| homepage | https://github.com/0x6b/sha2_hasher |
| repository | https://github.com/0x6b/sha2_hasher |
| max_upload_size | |
| id | 2051717 |
| size | 20,040 |
A trait for hashing a file using the SHA-2 family of algorithms.
I found myself repeatedly writing code to hash files using the SHA256, so I wrote this tiny trait to make my life easier.
async: Enables the async implementation.sync: Enables the sync implementation.Note: async and sync features are mutually exclusive. One must be enabled.
// Enable with: --features async
use sha2_hasher::Sha2Hasher;
#[tokio::main(flavor = "current_thread")]
async fn main() {
let hash = std::path::Path::new(".gitignore").sha256().await.unwrap();
println!("{hash}");
}
// Enable with: --features sync
use sha2_hasher::Sha2Hasher;
fn main() {
let hash = std::path::Path::new(".gitignore").sha256().unwrap();
println!("{hash}");
}
MIT. See LICENSE for details.