pub fn multi_hash<D: Digest>(data: &[u8], levels: usize) -> Vec<u8> ⓘExpand description
Multi-level hash (hash of hash).
This function applies hashing multiple times, hashing the result of the previous hash. This can be useful for certain cryptographic constructions.
§Type Parameters
D- A hasher type implementingDigest
§Arguments
data- The data to hashlevels- The number of times to hash (0 means no hashing, 1 means hash once, etc.)
§Returns
The final hash output after applying hashing levels times
§Example
use rust_bottle::hash::multi_hash;
use sha2::Sha256;
let data = b"Hello, world!";
let hash = multi_hash::<Sha256>(data, 3); // Hash 3 times