Module lair_keystore_api::dependencies::sodoken::hash::blake2b
source · Expand description
Api functions related to the blake2b generichash algorithm.
Blake2b is a fast generic hashing algorithm.
§Example if you have all the data ahead of time:
let hash = <sodoken::BufWriteSized<32>>::new_no_lock();
sodoken::hash::blake2b::hash(
hash.clone(),
b"test-data".to_vec(),
).await.unwrap();
let hash = hash.to_read_sized();
assert_eq!(&[168, 70, 104, 97], &hash.read_lock()[..4]);
§Stream hashing example:
let mut hasher = <sodoken::hash::blake2b::Blake2bHash<32>>::new().unwrap();
hasher.update(b"test".to_vec()).await.unwrap();
hasher.update(b"-".to_vec()).await.unwrap();
hasher.update(b"data".to_vec()).await.unwrap();
let hash = sodoken::BufWriteSized::new_no_lock();
hasher.finish(hash.clone()).unwrap();
let hash = hash.to_read_sized();
assert_eq!(&[168, 70, 104, 97], &hash.read_lock()[..4]);
Structs§
- A streaming hash instance.
Constants§
- maximum generichash/blake2b output hash size
- minimum generichash/blake2b output hash size
- maximum generichash/blake2b key size
- minimum generichash/blake2b key size
Functions§
- blake2b hashing scheme
- blake2b hashing scheme