Function multihash::encode [] [src]

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

Encodes data into a multihash.

The returned data is raw bytes. To make is more human-friendly, you can encode it (hex, base58, base64, etc).

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 multihash::{encode, Hash};

assert_eq!(
    encode(Hash::SHA2256, b"hello world").unwrap(),
    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]
);