write-hasher

Crates.iowrite-hasher
lib.rswrite-hasher
version0.1.2
sourcesrc
created_at2023-04-27 10:15:49.651527
updated_at2023-05-24 09:39:24.473854
descriptionTransparently calculate hash on (asynchronously) writing to an type
homepagehttps://github.com/uttarayan21/write-hasher
repositoryhttps://github.com/uttarayan21/write-hasher
max_upload_size
id850220
size18,976
Uttarayan Mondal (uttarayan21)

documentation

https://docs.rs/write-hasher

README

WriteHasher

Hash the data being written to a writer.
Supports tokio::io::AsyncWrite, futures::io::AsyncWrite, std::io::Write.

Example

extern crate sha2;
use sha2::Sha256;
use write_hasher::WriteHasher;

let mut file = std::fs::File::open("Cargo.toml").unwrap();
let dest = std::io::sink();
let dest = WriteHasher::<Sha256, _>::new(dest);
std::io::copy(&mut file, &mut dest).unwrap();
let hash = dest.finalize();

You can use async functions as well as std functions for this as well.

Commit count: 10

cargo fmt