Crate ya_md5

source ·
Expand description

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

§Example

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

fn example() -> Result<(), Md5Error> {
    std::fs::write("foo.txt", b"hello world")?;
    let hash = {
        let mut file = File::open("foo.txt")?;
        Md5Hasher::hash(&mut file)?
    };
    std::fs::remove_file("foo.txt")?;
    let result = format!("{}", hash);
    assert_eq!(result, "5eb63bbbe01eeed093cb22bb8f5acdc3");
    Ok(())
}

Structs§

  • The hash computed by the Md5Hasher.
  • A hasher thath computes the MD5 hash of a given list of chunks.

Enums§