Skip to main content

Library for generating IPFS v1 CIDs

Project description

ipfs-cid

pypi test codecov

A library for building IPFS CID v1 compatible content identifiers using fixed encoding parameters.

Usage

from ipfs_cid import encode_cid_v1

data = b"Hello world"
result = encode_cid_v1(data)
# result is now "bafkreide5semuafsnds3ugrvm6fbwuyw2ijpj43gwjdxemstjkfozi37hq"

Encoding Format

The CID spec supports multiple different encodings and hashing algorithms.

The resulting CID string is composed of the following components:

{multibase prefix} + multibase_encoded({cid version} + {content type} + {multihash})

This library always uses the following encoding parameters:

multibase CID version Content Type Multihash
base32 cidv1 raw sha2-256

More details about the formats below:

Multibase

encoding code description
base32 b rfc4648 case-insensitive - no padding

Multicodec

name code description
cidv1 0x01 CID v1
sha2-256 0x12 sha2-256 with 256 bit digest
raw 0x55 raw binary

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipfs_cid-0.1.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

ipfs_cid-0.1.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page