pub struct Blake2b { /* private fields */ }
Expand description
BLAKE2b streaming state.
Implementations§
source§impl Blake2b
impl Blake2b
sourcepub fn new(size: usize) -> Result<Self, UnknownCryptoError>
pub fn new(size: usize) -> Result<Self, UnknownCryptoError>
Initialize a Blake2b
struct with a given size (in bytes).
sourcepub fn reset(&mut self) -> Result<(), UnknownCryptoError>
pub fn reset(&mut self) -> Result<(), UnknownCryptoError>
Reset to new()
state.
sourcepub fn update(&mut self, data: &[u8]) -> Result<(), UnknownCryptoError>
pub fn update(&mut self, data: &[u8]) -> Result<(), UnknownCryptoError>
Update state with data
. This can be called multiple times.
sourcepub fn finalize(&mut self) -> Result<Digest, UnknownCryptoError>
pub fn finalize(&mut self) -> Result<Digest, UnknownCryptoError>
Return a BLAKE2b digest.
Trait Implementations§
source§impl Write for Blake2b
Available on crate feature safe_api
only.
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>
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>
fn flush(&mut self) -> Result<(), Error>
This type doesn’t buffer writes, so flushing is a no-op.
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
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>
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
Auto Trait Implementations§
impl RefUnwindSafe for Blake2b
impl Send for Blake2b
impl Sync for Blake2b
impl Unpin for Blake2b
impl UnwindSafe for Blake2b
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more