sha2_hasher

Crates.iosha2_hasher
lib.rssha2_hasher
version0.3.2
created_at2026-01-18 03:37:46.119342+00
updated_at2026-01-18 06:34:55.377887+00
descriptionA trait extension for hashing files with SHA-2 algorithms
homepagehttps://github.com/0x6b/sha2_hasher
repositoryhttps://github.com/0x6b/sha2_hasher
max_upload_size
id2051717
size20,040
kaoru (0x6b)

documentation

https://docs.rs/sha2_hasher

README

sha2_hasher

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.

Crate Features

  • async: Enables the async implementation.
  • sync: Enables the sync implementation.

Note: async and sync features are mutually exclusive. One must be enabled.

Usage

Async

// 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}");
}

Sync

// Enable with: --features sync
use sha2_hasher::Sha2Hasher;

fn main() {
    let hash = std::path::Path::new(".gitignore").sha256().unwrap();
    println!("{hash}");
}

License

MIT. See LICENSE for details.

Commit count: 21

cargo fmt