[−][src]Trait digest::Digest
The Digest
trait specifies an interface common for digest functions.
It's a convenience wrapper around Input
, FixedOutput
, Reset
, Clone
,
and Default
traits. It also provides additional convenience methods.
Associated Types
type OutputSize: ArrayLength<u8>
Required methods
fn new() -> Self
Create new hasher instance
fn input<B: AsRef<[u8]>>(&mut self, data: B)
Digest input data.
This method can be called repeatedly for use with streaming messages.
fn chain<B: AsRef<[u8]>>(self, data: B) -> Self where
Self: Sized,
Self: Sized,
Digest input data in a chained manner.
fn result(self) -> GenericArray<u8, Self::OutputSize>
Retrieve result and consume hasher instance.
fn result_reset(&mut self) -> GenericArray<u8, Self::OutputSize>
Retrieve result and reset hasher instance.
This method sometimes can be more efficient compared to hasher re-creation.
fn reset(&mut self)
Reset hasher instance to its initial state.
fn output_size() -> usize
Get output size of the hasher
fn digest(data: &[u8]) -> GenericArray<u8, Self::OutputSize>
Convenience function to compute hash of the data
. It will handle
hasher creation, data feeding and finalization.
Example:
ⓘThis example is not tested
println!("{:x}", sha2::Sha256::digest(b"Hello world"));
Implementors
impl<D: Input + FixedOutput + Reset + Clone + Default> Digest for D
[src]
type OutputSize = Self::OutputSize
fn new() -> Self
[src]
fn input<B: AsRef<[u8]>>(&mut self, data: B)
[src]
fn chain<B: AsRef<[u8]>>(self, data: B) -> Self where
Self: Sized,
[src]
Self: Sized,