[][src]Function parity_multihash::encode

pub fn encode(hash: Hash, input: &[u8]) -> Result<Multihash, EncodeError>

Encodes data into a multihash.

Errors

Will return an error if the specified hash type is not supported. See the docs for Hash to see what is supported.

Examples

use parity_multihash::{encode, Hash};

assert_eq!(
    encode(Hash::SHA2256, b"hello world").unwrap().to_vec(),
    vec![18, 32, 185, 77, 39, 185, 147, 77, 62, 8, 165, 46, 82, 215, 218, 125, 171, 250, 196,
    132, 239, 227, 122, 83, 128, 238, 144, 136, 247, 172, 226, 239, 205, 233]
);