Trait sp_multihash::MultihashDigest [−][src]
pub trait MultihashDigest<const S: usize>: TryFrom<u64> + Into<u64> + Send + Sync + Unpin + Copy + Eq + Debug + 'static {
fn digest(&self, input: &[u8]) -> Multihash<S>;
fn multihash_from_digest<'a, D, const DIGEST_SIZE: usize>(
digest: &'a D
) -> Multihash<S>
where
D: Digest<DIGEST_SIZE>,
Self: From<&'a D>;
}
Expand description
Trait that implements hashing.
It is usually implemented by a custom code table enum that derives the
Multihash
derive.
Required methods
Calculate the hash of some input data.
Example
// `Code` implements `MultihashDigest`
use sp_multihash::{
Code,
MultihashDigest,
};
let hash = Code::Sha3_256.digest(b"Hello world!");
println!("{:02x?}", hash);