[][src]Struct sequoia_openpgp::crypto::hash::Context

pub struct Context { /* fields omitted */ }

State of a hash function.

This provides an abstract interface to the hash functions used in OpenPGP.

use sequoia_openpgp::types::HashAlgorithm;

// Create a context and feed data to it.
let mut ctx = HashAlgorithm::SHA512.context()?;
ctx.update(&b"The quick brown fox jumps over the lazy dog."[..]);

// Extract the digest.
let mut digest = vec![0; ctx.digest_size()];
ctx.digest(&mut digest);

use sequoia_openpgp::fmt::hex;


impl Context[src]

pub fn algo(&self) -> HashAlgorithm[src]

Returns the algorithm.

pub fn digest_size(&self) -> usize[src]

Size of the digest in bytes

pub fn update<D: AsRef<[u8]>>(&mut self, data: D)[src]

Writes data into the hash function.

pub fn digest<D: AsMut<[u8]>>(&mut self, digest: D)[src]

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

Resets the hash function contexts.

digest must be at least self.digest_size() bytes large, otherwise the digest will be truncated.

Trait Implementations

impl From<Context> for MDC[src]

impl Clone for Context[src]

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

Performs copy-assignment from source. Read more

impl Write for Context[src]

fn write_vectored(&mut self, bufs: &[IoVec]) -> Result<usize, Error>[src]

🔬 This is a nightly-only experimental API. (iovec)

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

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

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

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

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

fn by_ref(&mut self) -> &mut Self

Creates a "by reference" adaptor for this instance of Write. Read more

Auto Trait Implementations

impl !Send for Context

impl !Sync for Context

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized

impl<T> BorrowMut for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.