Trait ed25519_dalek::Digest[][src]

pub trait Digest {
    type OutputSize: ArrayLength<u8>;
    pub fn new() -> Self;
pub fn input<B>(&mut self, data: B)
    where
        B: AsRef<[u8]>
;
pub fn chain<B>(self, data: B) -> Self
    where
        B: AsRef<[u8]>
;
pub fn result(self) -> GenericArray<u8, Self::OutputSize>;
pub fn result_reset(&mut self) -> GenericArray<u8, Self::OutputSize>;
pub fn reset(&mut self);
pub fn output_size() -> usize;
pub fn digest(data: &[u8]) -> GenericArray<u8, Self::OutputSize>; }

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>[src]

Loading content...

Required methods

pub fn new() -> Self[src]

Create new hasher instance

pub fn input<B>(&mut self, data: B) where
    B: AsRef<[u8]>, 
[src]

Digest input data.

This method can be called repeatedly for use with streaming messages.

pub fn chain<B>(self, data: B) -> Self where
    B: AsRef<[u8]>, 
[src]

Digest input data in a chained manner.

pub fn result(self) -> GenericArray<u8, Self::OutputSize>[src]

Retrieve result and consume hasher instance.

pub fn result_reset(&mut self) -> GenericArray<u8, Self::OutputSize>[src]

Retrieve result and reset hasher instance.

This method sometimes can be more efficient compared to hasher re-creation.

pub fn reset(&mut self)[src]

Reset hasher instance to its initial state.

pub fn output_size() -> usize[src]

Get output size of the hasher

pub fn digest(data: &[u8]) -> GenericArray<u8, Self::OutputSize>[src]

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"));
Loading content...

Implementors

impl<D> Digest for D where
    D: Input + FixedOutput + Reset + Clone + Default
[src]

type OutputSize = <D as FixedOutput>::OutputSize

Loading content...