.. image:: https://img.shields.io/pypi/v/py-multiformats-cid.svg :target: https://pypi.python.org/pypi/py-multiformats-cid
CID <https://github.com/multiformats/cid>
is a format for referencing content in distributed information systems,
like IPFS <https://ipfs.io>
.
It leverages content addressing <https://en.wikipedia.org/wiki/Content-addressable_storage>
_,
cryptographic hashing <https://simple.wikipedia.org/wiki/Cryptographic_hash_function>
, and
self-describing formats <https://github.com/multiformats/multiformats>
.
It is the core identifier used by IPFS <https://ipfs.io>
and IPLD <https://ipld.io>
.
CID is a self-describing content-addressed identifier.
It uses cryptographic hashes to achieve content addressing.
It uses several multiformats <https://github.com/multiformats/multiformats>
to achieve flexible self-description,
namely multihash <https://github.com/multiformats/multihash>
for hashes,
multicodec <https://github.com/multiformats/multicodec>
for data content
types, and multibase <https://github.com/multiformats/multibase>
to encode the CID itself into strings.
.. code-block:: python
>>> from multiformats_cid import make_cid
>>> make_cid('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4')
CIDv0(version=0, codec=dag-pb, multihash=b"\x12 \xb9M'\xb9\x93M>\x08\xa5.R\xd7\xda}\xab\xfa\xc4\x84..")
>>> cid = make_cid('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4')
>>> print(cid.version, cid.codec, cid.multihash)
>>> print(cid.encode())
QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4
>>> str(cid)
'QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4'
Stable release
To install *py-multiformats-cid*, run this command in your terminal:
.. code-block:: console
$ pip install py-multiformats-cid
This is the preferred method to install CID, as it will always install the most recent stable release.
If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
From sources
The sources for py-multiformats-cid can be downloaded from the Github repo
_.
You can either clone the public repository:
.. code-block:: console
$ git clone https://github.com/pinnaculum/py-multiformats-cid
Or download the tarball
_:
.. code-block:: console
$ curl -OL https://github.com/pinnaculum/py-multiformats-cid/tarball/master
Once you have a copy of the source, you can install it with:
.. code-block:: console
$ python setup.py install
.. _Github repo: https://github.com/pinnaculum/py-multiformats-cid .. _tarball: https://github.com/pinnaculum/py-multiformats-cid/tarball/master