{"library":"py-cid","title":"py-cid: Self-describing content-addressed identifiers","description":"py-cid is a Python library that provides an implementation of the Content Identifier (CID) specification. CIDs are self-describing content-addressed identifiers used in distributed systems like IPFS and IPLD, leveraging cryptographic hashing and multiformats for flexible self-description. The library is actively maintained, with version 0.5.0 being the latest release, supporting Python 3.10 and newer.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install py-cid"],"cli":null},"imports":["from cid import make_cid","from cid import CIDv0","from cid import CIDv1"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from cid import make_cid, CIDv0, CIDv1\n\n# Create a CIDv0 from a base58-encoded multihash\ncid_v0_str = 'QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4'\ncid0 = make_cid(cid_v0_str)\nprint(f\"CIDv0: {cid0}\")\nprint(f\"Version: {cid0.version}, Codec: {cid0.codec}, Multihash: {cid0.multihash.hex()}\")\n\n# Create a CIDv1 from a multibase-encoded CID string\ncid_v1_str = 'bafybeigdyrzt5sfp7udm7hu76uh7y26nf3fzmsyqhwfsgr2zfdnc2dsxze'\ncid1 = make_cid(cid_v1_str)\nprint(f\"CIDv1: {cid1}\")\nprint(f\"Version: {cid1.version}, Codec: {cid1.codec}, Multihash: {cid1.multihash.hex()}\")\n\n# Accessing components\nprint(f\"CIDv0 string: {str(cid0)}\")\nprint(f\"CIDv1 encoded in base32: {cid1.encode('base32')}\") # requires py-multibase","lang":"python","description":"This quickstart demonstrates how to create CIDv0 and CIDv1 objects using `make_cid` from both base58 and multibase encoded strings. It also shows how to access their version, codec, multihash, and how to encode CIDv1 into different multibase formats.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}