Skip to main content

encode_cid

Function encode_cid 

Source
pub fn encode_cid(codec: Codec, algo: HashAlgo, digest: &[u8]) -> Result<String>
Expand description

Encode raw (codec, algo, digest) as a canonical CIDv1 base32 string.

The output always begins with the multibase base32 prefix b. Encoding is deterministic: identical inputs produce identical strings.

let cid = encode_cid(Codec::GitRaw, HashAlgo::Sha1, &[0u8; 20]).unwrap();
assert!(cid.starts_with('b'));