yet-another-md5

Crates.ioyet-another-md5
lib.rsyet-another-md5
version2.0.0
sourcesrc
created_at2024-02-17 08:56:22.873606
updated_at2024-03-13 22:27:58.448349
descriptionA library to compute md5 hashes from Read objects
homepage
repositoryhttps://github.com/Terseus/yet-another-md5
max_upload_size
id1143107
size34,995
David Caro (Terseus)

documentation

README

yet-another-md5

An implementation of the MD5 hash algorithm capable to hash data readed from a [std::io::Read] implementation.

Why?

The main motivation of this project is as an exercise to learn some Rust.

The second one is that the MD5 implementations I found for Rust hashes binary strings, which forced you to have the whole data to hash in memory; this looked silly to me given that the MD5 algorithm hash the data in chunks.

Usage

use std::fs::File;
use std::io::prelude::*;
use ya_md5::Md5Hasher;
use ya_md5::Hash;
use ya_md5::Md5Error;

fn main() -> Result<(), Md5Error> {
    let mut file = File::open("foo.txt")?;
    Md5Hasher::hash(&mut file)?
    let result = format!("{}", hash);
    assert_eq!(result, "5eb63bbbe01eeed093cb22bb8f5acdc3");
    Ok(())
}

See the docs.

Commit count: 0

cargo fmt