Multiformats.CID (multiformats v0.1.0)
Handles encoding and decoding CIDs using the multiformats library.
Summary
Functions
Decodes CID binary string into a CID struct.
Encodes binary content into a CIDv1 binary string. You control the descriptors and algorithms via the opts
Keyword list argument.
Encodes binary content into a CIDv0 binary string. This assumes the type of the content is dag-pb
, uses the sha2-256
hashing algorithm, and is base58btc
encoded (but without the z
prefix).
Only CIDv0 has an explicit check because all subsequent CID versions are self-describing and therefore you can just pop the version number off the binary string.
Types
@type t() :: %Multiformats.CID{ cid: binary(), content_address: binary(), content_type: binary(), hash_algorithm: binary(), hash_digest: binary(), hash_size: non_neg_integer(), version: non_neg_integer() }
Functions
Decodes CID binary string into a CID struct.
If the CID begins with the identity
prefix (0x00
), it is assumed to be a CIDv1 string with no multibase encoding.
Encodes binary content into a CIDv1 binary string. You control the descriptors and algorithms via the opts
Keyword list argument.
By default (i.e. when opts
is not given), the following values are used by default:
:content_type
is set to"raw"
:hash_algorithm
is set to"sha2-256"
:base
is set to:base32
Encodes binary content into a CIDv0 binary string. This assumes the type of the content is dag-pb
, uses the sha2-256
hashing algorithm, and is base58btc
encoded (but without the z
prefix).
Only CIDv0 has an explicit check because all subsequent CID versions are self-describing and therefore you can just pop the version number off the binary string.