Trait ed25519_dalek::Digest
source · pub trait Digest {
type OutputSize: ArrayLength<u8>;
// Required methods
fn new() -> Self;
fn update(&mut self, data: impl AsRef<[u8]>);
fn chain(self, data: impl AsRef<[u8]>) -> Self
where Self: Sized;
fn finalize(self) -> GenericArray<u8, Self::OutputSize>;
fn finalize_reset(&mut self) -> GenericArray<u8, Self::OutputSize>;
fn reset(&mut self);
fn output_size() -> usize;
fn digest(data: &[u8]) -> GenericArray<u8, Self::OutputSize>;
}
Expand description
The Digest
trait specifies an interface common for digest functions.
It’s a convenience wrapper around Update
, FixedOutput
, Reset
,
Clone
, and Default
traits. It also provides additional convenience methods.
Required Associated Types§
sourcetype OutputSize: ArrayLength<u8>
type OutputSize: ArrayLength<u8>
Output size for Digest
Required Methods§
sourcefn update(&mut self, data: impl AsRef<[u8]>)
fn update(&mut self, data: impl AsRef<[u8]>)
Digest data, updating the internal state.
This method can be called repeatedly for use with streaming messages.
sourcefn chain(self, data: impl AsRef<[u8]>) -> Selfwhere
Self: Sized,
fn chain(self, data: impl AsRef<[u8]>) -> Selfwhere Self: Sized,
Digest input data in a chained manner.
sourcefn finalize(self) -> GenericArray<u8, Self::OutputSize>
fn finalize(self) -> GenericArray<u8, Self::OutputSize>
Retrieve result and consume hasher instance.
sourcefn finalize_reset(&mut self) -> GenericArray<u8, Self::OutputSize>
fn finalize_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.
sourcefn output_size() -> usize
fn output_size() -> usize
Get output size of the hasher
sourcefn digest(data: &[u8]) -> GenericArray<u8, Self::OutputSize>
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:
ⓘ
println!("{:x}", sha2::Sha256::digest(b"Hello world"));