Struct crypto_hash::Hasher
[−]
[src]
pub struct Hasher { /* fields omitted */ }
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]
fn new(algorithm: Algorithm) -> Hasher
Create a new Hasher
for the given Algorithm
.
fn finish(&mut self) -> Vec<u8>
Generate a digest from the data written to the Hasher
.
Trait Implementations
impl Write for Hasher
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more