pub struct Blake3 { /* private fields */ }Expand description
BLAKE3 hash function.
Implements the Hasher trait.
§One-shot API
ⓘ
use crypto::{Hasher, blake3::Blake3};
let hash = Blake3::hash(b"hello world");§Incremental API
ⓘ
use crypto::{Hasher, blake3::Blake3};
let mut hasher = Blake3::new();
hasher.update(b"hello ");
hasher.update(b"world");
let hash = hasher.sum();§XOF (Extendable-Output Function) API
ⓘ
use crypto::{Hasher, blake3::Blake3};
let mut out = [0u8; 64];
let mut hasher = Blake3::new();
hasher.update(b"hello world");
hasher.finalize_xof().squeeze(&mut out);§Keyed hashing
ⓘ
use crypto::{Hasher, blake3::Blake3};
let key = b"whats the Elvish word for friend";
let mut hasher = Blake3::new_keyed(key);
hasher.update(b"hello world");
let hash = hasher.sum();The keyed_hash one-shot is also available:
ⓘ
use crypto::blake3::Blake3;
let key = b"whats the Elvish word for friend";
let hash = Blake3::keyed_hash(key, b"hello world");§Derive-key mode
ⓘ
use crypto::blake3::Blake3;
let key = Blake3::derive_key("my app context", b"key material");
let mut hasher = Blake3::new_keyed(&key);
hasher.update(b"hello world");
let hash = hasher.sum();Implementations§
Source§impl Blake3
impl Blake3
pub fn new_keyed(key: &[u8; 32]) -> Self
pub fn new_derive_key(context: &str) -> Self
pub fn derive_key(context: &str, key_material: &[u8]) -> [u8; 32]
pub fn keyed_hash(key: &[u8; 32], input: &[u8]) -> Hash
pub fn finalize_xof(self) -> Blake3XofReader
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Blake3
impl RefUnwindSafe for Blake3
impl Send for Blake3
impl Sync for Blake3
impl Unpin for Blake3
impl UnsafeUnpin for Blake3
impl UnwindSafe for Blake3
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