Trait nettle::hash::Hash

source ·
pub trait Hash {
    // Required methods
    fn digest_size(&self) -> usize;
    fn update(&mut self, data: &[u8]);
    fn digest(&mut self, digest: &mut [u8]);
    fn box_clone(&self) -> Box<dyn Hash>;
}
Expand description

Hash function.

Cryptographic hash functions compute a fixed length checksum (also called digest) from variable length data.

Required Methods§

source

fn digest_size(&self) -> usize

Size of the digest in bytes

source

fn update(&mut self, data: &[u8])

Writes data into the hash function.

source

fn digest(&mut self, digest: &mut [u8])

Finalizes the hash function and writes the digest into the provided slice.

digest must be at least DIGEST_SIZE bytes large, otherwise the digest will be truncated. Resets the hash function contexts.

source

fn box_clone(&self) -> Box<dyn Hash>

Clones the hash context into a Box.

Trait Implementations§

source§

impl Clone for Box<dyn Hash>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Hash for Box<dyn Hash>

source§

fn digest_size(&self) -> usize

Size of the digest in bytes
source§

fn update(&mut self, data: &[u8])

Writes data into the hash function.
source§

fn digest(&mut self, digest: &mut [u8])

Finalizes the hash function and writes the digest into the provided slice. Read more
source§

fn box_clone(&self) -> Box<dyn Hash>

Clones the hash context into a Box.
source§

impl Write for dyn Hash

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<()>

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

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

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

Implementations on Foreign Types§

source§

impl Hash for Box<dyn Hash>

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8])

source§

fn box_clone(&self) -> Box<dyn Hash>

Implementors§