pub struct Blake2b { /* private fields */ }
Expand description

BLAKE2b streaming state.

Implementations§

source§

impl Blake2b

source

pub fn new(size: usize) -> Result<Self, UnknownCryptoError>

Initialize a Blake2b struct with a given size (in bytes).

source

pub fn reset(&mut self) -> Result<(), UnknownCryptoError>

Reset to new() state.

source

pub fn update(&mut self, data: &[u8]) -> Result<(), UnknownCryptoError>

Update state with data. This can be called multiple times.

source

pub fn finalize(&mut self) -> Result<Digest, UnknownCryptoError>

Return a BLAKE2b digest.

Trait Implementations§

source§

impl Clone for Blake2b

source§

fn clone(&self) -> Blake2b

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 Debug for Blake2b

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Write for Blake2b

Available on crate feature safe_api only.

Example: custom digest size.

use orion::{
    hazardous::hash::blake2::blake2b::{Blake2b, Digest},
    errors::UnknownCryptoError,
};
use std::io::{self, Read, Write};

// `reader` could also be a `File::open(...)?`.
let mut reader = io::Cursor::new(b"some data");
let mut hasher = Blake2b::new(64)?; // 512-bit hash
std::io::copy(&mut reader, &mut hasher)?;

let digest: Digest = hasher.finalize()?;
source§

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

Update the hasher’s internal state with all of the bytes given. If this function returns the Ok variant, it’s guaranteed that it will contain the length of the buffer passed to Write. Note that this function is just a small wrapper over Blake2b::update.

Errors:

This function will only ever return the std::io::ErrorKind::Other variant when it returns an error. Additionally, this will always contain Orion’s UnknownCryptoError type.

source§

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

This type doesn’t buffer writes, so flushing is a no-op.

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
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.