dwyl / cid

❄️cid ("content id") is a human-friendly (readable/typeable) unique ID function built for distributed/decentralised systems.
GNU General Public License v2.0
34 stars 3 forks source link

How to detect multibase of a CID #15

Open SimonLab opened 5 years ago

SimonLab commented 5 years ago

Given a CID the first step when decoding the CID is to determine which multibase is used see https://github.com/multiformats/multibase

The CID(v1) encode this information on the first byte (ie the first 8 bits), see https://github.com/multiformats/cid#decoding-algorithm where:

image

image

SimonLab commented 5 years ago

Knowing the encoding is in fact simple.

see image