Struct crypto_hash::Hasher [] [src]

pub struct Hasher(_);

Generator of digests using a cryptographic hash function.

Examples

use crypto_hash::{Algorithm, Hasher};
use std::io::Write;

let mut hasher = Hasher::new(Algorithm::SHA256);
hasher.write_all(b"crypto");
hasher.write_all(b"-");
hasher.write_all(b"hash");
let result = hasher.finish();
let expected =
    b"\xfd\x1a\xfb`\"\xcdMG\xc8\x90\x96\x1cS9(\xea\xcf\xe8!\x9f\x1b%$\xf7\xfb*a\x84}\xdf\x8c'"
    .to_vec();
assert_eq!(expected, result)

Methods

impl Hasher
[src]

Create a new Hasher for the given Algorithm.

Generate a digest from the data written to the Hasher.

Trait Implementations

impl Write for Hasher
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more