makkus.multiformats


Namemakkus.multiformats JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/hashberg-io/multiformats
SummaryForked from the original author until they incorporate latest fixes; Python implementation of multiformats protocols.
upload_time2023-11-28 09:47:49
maintainer
docs_urlNone
authorhashberg
requires_python>=3.8
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            multiformats: Python implementation of `multiformat protocols <https://multiformats.io/>`_
============================================================================================

.. image:: https://img.shields.io/badge/python-3.7+-green.svg
    :target: https://docs.python.org/3.7/
    :alt: Python versions

.. image:: https://img.shields.io/pypi/v/multiformats.svg
    :target: https://pypi.python.org/pypi/multiformats/
    :alt: PyPI version

.. image:: https://img.shields.io/pypi/status/multiformats.svg
    :target: https://pypi.python.org/pypi/multiformats/
    :alt: PyPI status

.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
    :target: https://github.com/python/mypy
    :alt: Checked with Mypy
    
.. image:: https://readthedocs.org/projects/multiformats/badge/?version=latest
    :target: https://multiformats.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

.. image:: https://github.com/hashberg-io/multiformats/actions/workflows/python-pytest.yml/badge.svg
    :target: https://github.com/hashberg-io/multiformats/actions/workflows/python-pytest.yml
    :alt: Python package status

.. image:: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square
    :target: https://github.com/RichardLitt/standard-readme
    :alt: standard-readme compliant


Multiformats is a compliant implementation of `multiformat protocols <https://multiformats.io/>`_:

This is a temporary fork of the original project to be used until the original project incorporates a bug fix to work with newer versions of the 'typing_extensions' dependency. Python versions 3.11 & 3.12 are not tested with this fork.

Bug: https://github.com/hashberg-io/typing-validation/issues/1

.. contents::


Install
-------

You can install the latest release from `PyPI <https://pypi.org/project/multiformats/>`_ as follows:

.. code-block:: console

    $ pip install --upgrade multiformats

The following are mandatory dependencies for this module:

- `typing-extensions <https://github.com/python/typing_extensions>`_, for backward compatibility of static typing.
- `typing-validation <https://github.com/hashberg-io/typing-validation>`_, for dynamic typechecking
- `bases <https://github.com/hashberg-io/bases>`_, for implementation of base encodings used by Multibase

The following are optional dependencies for this module:

- `pysha3 <https://github.com/tiran/pysha3>`_, for the ``keccak`` hash functions.
- `blake3 <https://github.com/oconnor663/blake3-py>`_, for the ``blake3`` hash function.
- `pyskein <https://pythonhosted.org/pyskein/>`_, for the ``skein`` hash functions.
- `mmh3 <https://github.com/hajimes/mmh3>`_, for the ``murmur3`` hash functions.
- `pycryptodomex <https://github.com/Legrandin/pycryptodome/>`_, for the ``ripemd-160`` hash function, \
  the ``kangarootwelve`` hash function and the ``sha2-512-224``/``sha2-512-256`` hash functions.

You can install the latest release together with all optional dependencies as follows:

.. code-block:: console

    $ pip install --upgrade multiformats[full]


Usage
-----

You can import multiformat protocols directly from top level:

>>> from multiformats import *

The above will import the following names:

.. code-block:: python

    varint, multicodec, multibase, multihash, multiaddr, CID

The first five are modules implementing the homonymous specifications, while ``CID`` is a class for Content IDentifiers.
Below are some basic usage examples, to get you started: for detailed documentation, see https://multiformats.readthedocs.io/


Varint encode/decode
^^^^^^^^^^^^^^^^^^^^

>>> varint.encode(128)
b'\x80\x01'
>>> varint.decode(b'\x80\x01')
128


Multicodec wrap/unwrap
^^^^^^^^^^^^^^^^^^^^^^

Procedural style:

>>> raw_data = bytes([192, 168, 0, 254])
>>> multicodec_data = multicodec.wrap("ip4", raw_data)
>>> raw_data.hex()
  'c0a800fe'
>>> multicodec_data.hex()
'04c0a800fe'
>>> codec, _raw_data = multicodec.unwrap(multicodec_data)
>>> _raw_data.hex()
  'c0a800fe'
>>> codec
Multicodec(name='ip4', tag='multiaddr', code='0x04',
           status='permanent', description='')

Object-oriented style:

>>> ip4 = multicodec.get("ip4")
>>> ip4
Multicodec(name='ip4', tag='multiaddr', code='0x04',
           status='permanent', description='')
>>> raw_data = bytes([192, 168, 0, 254])
>>> multicodec_data = ip4.wrap(raw_data)
>>> raw_data.hex()
  'c0a800fe'
>>> multicodec_data.hex()
'04c0a800fe'
>>> ip4.unwrap(multicodec_data).hex()
  'c0a800fe'


Multibase encode/decode
^^^^^^^^^^^^^^^^^^^^^^^

Procedural style:

>>> multibase.encode(b"Hello World!", "base32")
'bjbswy3dpeblw64tmmqqq'
>>> multibase.decode('bjbswy3dpeblw64tmmqqq')
b'Hello World!'

Object-oriented style:

>>> base32 = multibase.get("base32")
>>> base32.encode(b"Hello World!")
'bjbswy3dpeblw64tmmqqq'
>>> base32.decode('bjbswy3dpeblw64tmmqqq')
b'Hello World!'


Multihash digest
^^^^^^^^^^^^^^^^

Procedural style:

>>> data = b"Hello world!"
>>> digest = multihash.digest(data, "sha2-256")
>>> digest.hex()
'1220c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a'

Object-oriented style:

>>> sha2_256 = multihash.get("sha2-256")
>>> digest = sha2_256.digest(data)
>>> digest.hex()
'1220c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a'

Optional truncated digests:

>>> digest = multihash.digest(data, "sha2-256", size=20)
#        optional truncated hash size, in bytes ^^^^^^^
>>> digest.hex()
'1214c0535e4be2b79ffd93291305436bf889314e4a3f'


Multihash wrap/unwrap
^^^^^^^^^^^^^^^^^^^^^

Procedural style:

>>> digest.hex()
'1214c0535e4be2b79ffd93291305436bf889314e4a3f'
>>> raw_digest = multihash.unwrap(digest)
>>> raw_digest.hex()
    'c0535e4be2b79ffd93291305436bf889314e4a3f'
>>> multihash.wrap(raw_digest, "sha2-256").hex()
'1214c0535e4be2b79ffd93291305436bf889314e4a3f'

Object-oriented style:

>>> sha2_256 = multihash.get("sha2-256")
>>> raw_digest = sha2_256.unwrap(digest)
>>> raw_digest.hex()
    'c0535e4be2b79ffd93291305436bf889314e4a3f'
>>> sha2_256.wrap(raw_digest).hex()
'1214c0535e4be2b79ffd93291305436bf889314e4a3f'


CID encode/decode
^^^^^^^^^^^^^^^^^

Decoding from multibase encoded strings:

>>> cid = CID.decode("zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA")
>>> cid
CID('base58btc', 1, 'raw',
  '12206e6ff7950a36187a801613426e858dce686cd7d7e3c0fc42ee0330072d245c95')
>>> cid.base
Multibase(name='base58btc', code='z',
          status='default', description='base58 bitcoin')
>>> cid.codec
Multicodec(name='raw', tag='ipld', code='0x55',
           status='permanent', description='raw binary')
>>> cid.digest.hex()
'12206e6ff7950a36187a801613426e858dce686cd7d7e3c0fc42ee0330072d245c95'
>>> cid.hashfun
Multicodec(name='sha2-256', tag='multihash', code='0x12',
           status='permanent', description='')
>>> cid.raw_digest.hex()
    '6e6ff7950a36187a801613426e858dce686cd7d7e3c0fc42ee0330072d245c95'

Multibase encoding:

>>> str(cid) # encode with own multibase 'base58btc'
'zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA'
>>> cid.encode("base32") # encode with different multibase
'bafkreidon73zkcrwdb5iafqtijxildoonbwnpv7dyd6ef3qdgads2jc4su'


PeerID creation
^^^^^^^^^^^^^^^

Creation of `CIDv1 PeerIDs <https://docs.libp2p.io/concepts/peer-id/>`_:

>>> pk_bytes = bytes.fromhex( # hex-string of 32-byte Ed25519 public key
... "1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93")
>>> peer_id = CID.peer_id(pk_bytes)
>>> peer_id
CID('base32', 1, 'libp2p-key',
'00201498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93')
#^^   0x00 = 'identity' multihash used (public key length <= 42)
#  ^^ 0x20 = 32-bytes of raw hash digest length
>>> str(peer_id)
'bafzaaiautc2um6td375c3soz4bu4v4dv2fx4gp65jq5qdp5nvzsdg5t5sm'


Multiaddr parse/decode
^^^^^^^^^^^^^^^^^^^^^^

>>> s = '/ip4/127.0.0.1/udp/9090/quic'
>>> multiaddr.parse(s)
Multiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'), Proto('quic'))
>>> b = bytes.fromhex('047f00000191022382cc03')
>>> multiaddr.decode(b)
Multiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'), Proto('quic'))


Multiaddr protocols/addresses
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Accessing multiaddr protocols:

>>> ip4 = multiaddr.proto("ip4")
>>> ip4
Proto("ip4")
>>> udp = multiaddr.proto("udp")
>>> quic = multiaddr.proto("quic")

Creating protocol addresses from human-readable strings:

>>> a = ip4/"192.168.1.1"
>>> a
Addr('ip4', '192.168.1.1')
>>> str(a)
'/ip4/192.168.1.1'
>>> a.value
'192.168.1.1'
>>> bytes(a).hex()
'04c0a80101'
>>> a.value_bytes.hex()
  'c0a80101'

Creating protocol addresses from bytestrings:

>>> a = ip4/bytes([192, 168, 1, 1])
>>> a
Addr('ip4', '192.168.1.1')


Multiaddr encapsulation/decapsulation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Creating multiaddresses by protocol encapsulation:

>>> ma = ip4/"127.0.0.1"/udp/9090/quic
>>> ma
Multiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'), Proto('quic'))
>>> str(ma)
'/ip4/127.0.0.1/udp/9090/quic'

Bytes for multiaddrs are computed according to the `(TLV)+ multiaddr format <https://multiformats.io/multiaddr/>`_:

>>> bytes(ip4/"127.0.0.1").hex()
'047f000001'
>>> bytes(udp/9090).hex()
          '91022382'
>>> bytes(quic).hex()
                  'cc03'
>>> bytes(ma).hex()
'047f00000191022382cc03'

Protocol decapsulation by indexing and slicing:

>>> ma[0]
Addr('ip4', '127.0.0.1')
>>> ma[:2]
Multiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'))
>>> ma[1:]
Multiaddr(Addr('udp', '9090'), Proto('quic'))


API
---

For the full API documentation, see https://multiformats.readthedocs.io/

The tables specifying all multicodecs and multibases known to this package are maintained as part of the `multiformats-config <https://github.com/hashberg-io/multiformats-config>`_ repository.


Contributing
------------

Please see `<CONTRIBUTING.md>`_.


License
-------

`MIT © Hashberg Ltd. <LICENSE>`_

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hashberg-io/multiformats",
    "name": "makkus.multiformats",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "hashberg",
    "author_email": "sg495@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/57/b9/333af4e9af51f97fce1cd0a43dc1c742c88505cc6cab2ed745ae4f8bb3d4/makkus.multiformats-0.2.4.tar.gz",
    "platform": null,
    "description": "multiformats: Python implementation of `multiformat protocols <https://multiformats.io/>`_\n============================================================================================\n\n.. image:: https://img.shields.io/badge/python-3.7+-green.svg\n    :target: https://docs.python.org/3.7/\n    :alt: Python versions\n\n.. image:: https://img.shields.io/pypi/v/multiformats.svg\n    :target: https://pypi.python.org/pypi/multiformats/\n    :alt: PyPI version\n\n.. image:: https://img.shields.io/pypi/status/multiformats.svg\n    :target: https://pypi.python.org/pypi/multiformats/\n    :alt: PyPI status\n\n.. image:: http://www.mypy-lang.org/static/mypy_badge.svg\n    :target: https://github.com/python/mypy\n    :alt: Checked with Mypy\n    \n.. image:: https://readthedocs.org/projects/multiformats/badge/?version=latest\n    :target: https://multiformats.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://github.com/hashberg-io/multiformats/actions/workflows/python-pytest.yml/badge.svg\n    :target: https://github.com/hashberg-io/multiformats/actions/workflows/python-pytest.yml\n    :alt: Python package status\n\n.. image:: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square\n    :target: https://github.com/RichardLitt/standard-readme\n    :alt: standard-readme compliant\n\n\nMultiformats is a compliant implementation of `multiformat protocols <https://multiformats.io/>`_:\n\nThis is a temporary fork of the original project to be used until the original project incorporates a bug fix to work with newer versions of the 'typing_extensions' dependency. Python versions 3.11 & 3.12 are not tested with this fork.\n\nBug: https://github.com/hashberg-io/typing-validation/issues/1\n\n.. contents::\n\n\nInstall\n-------\n\nYou can install the latest release from `PyPI <https://pypi.org/project/multiformats/>`_ as follows:\n\n.. code-block:: console\n\n    $ pip install --upgrade multiformats\n\nThe following are mandatory dependencies for this module:\n\n- `typing-extensions <https://github.com/python/typing_extensions>`_, for backward compatibility of static typing.\n- `typing-validation <https://github.com/hashberg-io/typing-validation>`_, for dynamic typechecking\n- `bases <https://github.com/hashberg-io/bases>`_, for implementation of base encodings used by Multibase\n\nThe following are optional dependencies for this module:\n\n- `pysha3 <https://github.com/tiran/pysha3>`_, for the ``keccak`` hash functions.\n- `blake3 <https://github.com/oconnor663/blake3-py>`_, for the ``blake3`` hash function.\n- `pyskein <https://pythonhosted.org/pyskein/>`_, for the ``skein`` hash functions.\n- `mmh3 <https://github.com/hajimes/mmh3>`_, for the ``murmur3`` hash functions.\n- `pycryptodomex <https://github.com/Legrandin/pycryptodome/>`_, for the ``ripemd-160`` hash function, \\\n  the ``kangarootwelve`` hash function and the ``sha2-512-224``/``sha2-512-256`` hash functions.\n\nYou can install the latest release together with all optional dependencies as follows:\n\n.. code-block:: console\n\n    $ pip install --upgrade multiformats[full]\n\n\nUsage\n-----\n\nYou can import multiformat protocols directly from top level:\n\n>>> from multiformats import *\n\nThe above will import the following names:\n\n.. code-block:: python\n\n    varint, multicodec, multibase, multihash, multiaddr, CID\n\nThe first five are modules implementing the homonymous specifications, while ``CID`` is a class for Content IDentifiers.\nBelow are some basic usage examples, to get you started: for detailed documentation, see https://multiformats.readthedocs.io/\n\n\nVarint encode/decode\n^^^^^^^^^^^^^^^^^^^^\n\n>>> varint.encode(128)\nb'\\x80\\x01'\n>>> varint.decode(b'\\x80\\x01')\n128\n\n\nMulticodec wrap/unwrap\n^^^^^^^^^^^^^^^^^^^^^^\n\nProcedural style:\n\n>>> raw_data = bytes([192, 168, 0, 254])\n>>> multicodec_data = multicodec.wrap(\"ip4\", raw_data)\n>>> raw_data.hex()\n  'c0a800fe'\n>>> multicodec_data.hex()\n'04c0a800fe'\n>>> codec, _raw_data = multicodec.unwrap(multicodec_data)\n>>> _raw_data.hex()\n  'c0a800fe'\n>>> codec\nMulticodec(name='ip4', tag='multiaddr', code='0x04',\n           status='permanent', description='')\n\nObject-oriented style:\n\n>>> ip4 = multicodec.get(\"ip4\")\n>>> ip4\nMulticodec(name='ip4', tag='multiaddr', code='0x04',\n           status='permanent', description='')\n>>> raw_data = bytes([192, 168, 0, 254])\n>>> multicodec_data = ip4.wrap(raw_data)\n>>> raw_data.hex()\n  'c0a800fe'\n>>> multicodec_data.hex()\n'04c0a800fe'\n>>> ip4.unwrap(multicodec_data).hex()\n  'c0a800fe'\n\n\nMultibase encode/decode\n^^^^^^^^^^^^^^^^^^^^^^^\n\nProcedural style:\n\n>>> multibase.encode(b\"Hello World!\", \"base32\")\n'bjbswy3dpeblw64tmmqqq'\n>>> multibase.decode('bjbswy3dpeblw64tmmqqq')\nb'Hello World!'\n\nObject-oriented style:\n\n>>> base32 = multibase.get(\"base32\")\n>>> base32.encode(b\"Hello World!\")\n'bjbswy3dpeblw64tmmqqq'\n>>> base32.decode('bjbswy3dpeblw64tmmqqq')\nb'Hello World!'\n\n\nMultihash digest\n^^^^^^^^^^^^^^^^\n\nProcedural style:\n\n>>> data = b\"Hello world!\"\n>>> digest = multihash.digest(data, \"sha2-256\")\n>>> digest.hex()\n'1220c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a'\n\nObject-oriented style:\n\n>>> sha2_256 = multihash.get(\"sha2-256\")\n>>> digest = sha2_256.digest(data)\n>>> digest.hex()\n'1220c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a'\n\nOptional truncated digests:\n\n>>> digest = multihash.digest(data, \"sha2-256\", size=20)\n#        optional truncated hash size, in bytes ^^^^^^^\n>>> digest.hex()\n'1214c0535e4be2b79ffd93291305436bf889314e4a3f'\n\n\nMultihash wrap/unwrap\n^^^^^^^^^^^^^^^^^^^^^\n\nProcedural style:\n\n>>> digest.hex()\n'1214c0535e4be2b79ffd93291305436bf889314e4a3f'\n>>> raw_digest = multihash.unwrap(digest)\n>>> raw_digest.hex()\n    'c0535e4be2b79ffd93291305436bf889314e4a3f'\n>>> multihash.wrap(raw_digest, \"sha2-256\").hex()\n'1214c0535e4be2b79ffd93291305436bf889314e4a3f'\n\nObject-oriented style:\n\n>>> sha2_256 = multihash.get(\"sha2-256\")\n>>> raw_digest = sha2_256.unwrap(digest)\n>>> raw_digest.hex()\n    'c0535e4be2b79ffd93291305436bf889314e4a3f'\n>>> sha2_256.wrap(raw_digest).hex()\n'1214c0535e4be2b79ffd93291305436bf889314e4a3f'\n\n\nCID encode/decode\n^^^^^^^^^^^^^^^^^\n\nDecoding from multibase encoded strings:\n\n>>> cid = CID.decode(\"zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA\")\n>>> cid\nCID('base58btc', 1, 'raw',\n  '12206e6ff7950a36187a801613426e858dce686cd7d7e3c0fc42ee0330072d245c95')\n>>> cid.base\nMultibase(name='base58btc', code='z',\n          status='default', description='base58 bitcoin')\n>>> cid.codec\nMulticodec(name='raw', tag='ipld', code='0x55',\n           status='permanent', description='raw binary')\n>>> cid.digest.hex()\n'12206e6ff7950a36187a801613426e858dce686cd7d7e3c0fc42ee0330072d245c95'\n>>> cid.hashfun\nMulticodec(name='sha2-256', tag='multihash', code='0x12',\n           status='permanent', description='')\n>>> cid.raw_digest.hex()\n    '6e6ff7950a36187a801613426e858dce686cd7d7e3c0fc42ee0330072d245c95'\n\nMultibase encoding:\n\n>>> str(cid) # encode with own multibase 'base58btc'\n'zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA'\n>>> cid.encode(\"base32\") # encode with different multibase\n'bafkreidon73zkcrwdb5iafqtijxildoonbwnpv7dyd6ef3qdgads2jc4su'\n\n\nPeerID creation\n^^^^^^^^^^^^^^^\n\nCreation of `CIDv1 PeerIDs <https://docs.libp2p.io/concepts/peer-id/>`_:\n\n>>> pk_bytes = bytes.fromhex( # hex-string of 32-byte Ed25519 public key\n... \"1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93\")\n>>> peer_id = CID.peer_id(pk_bytes)\n>>> peer_id\nCID('base32', 1, 'libp2p-key',\n'00201498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93')\n#^^   0x00 = 'identity' multihash used (public key length <= 42)\n#  ^^ 0x20 = 32-bytes of raw hash digest length\n>>> str(peer_id)\n'bafzaaiautc2um6td375c3soz4bu4v4dv2fx4gp65jq5qdp5nvzsdg5t5sm'\n\n\nMultiaddr parse/decode\n^^^^^^^^^^^^^^^^^^^^^^\n\n>>> s = '/ip4/127.0.0.1/udp/9090/quic'\n>>> multiaddr.parse(s)\nMultiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'), Proto('quic'))\n>>> b = bytes.fromhex('047f00000191022382cc03')\n>>> multiaddr.decode(b)\nMultiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'), Proto('quic'))\n\n\nMultiaddr protocols/addresses\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nAccessing multiaddr protocols:\n\n>>> ip4 = multiaddr.proto(\"ip4\")\n>>> ip4\nProto(\"ip4\")\n>>> udp = multiaddr.proto(\"udp\")\n>>> quic = multiaddr.proto(\"quic\")\n\nCreating protocol addresses from human-readable strings:\n\n>>> a = ip4/\"192.168.1.1\"\n>>> a\nAddr('ip4', '192.168.1.1')\n>>> str(a)\n'/ip4/192.168.1.1'\n>>> a.value\n'192.168.1.1'\n>>> bytes(a).hex()\n'04c0a80101'\n>>> a.value_bytes.hex()\n  'c0a80101'\n\nCreating protocol addresses from bytestrings:\n\n>>> a = ip4/bytes([192, 168, 1, 1])\n>>> a\nAddr('ip4', '192.168.1.1')\n\n\nMultiaddr encapsulation/decapsulation\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nCreating multiaddresses by protocol encapsulation:\n\n>>> ma = ip4/\"127.0.0.1\"/udp/9090/quic\n>>> ma\nMultiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'), Proto('quic'))\n>>> str(ma)\n'/ip4/127.0.0.1/udp/9090/quic'\n\nBytes for multiaddrs are computed according to the `(TLV)+ multiaddr format <https://multiformats.io/multiaddr/>`_:\n\n>>> bytes(ip4/\"127.0.0.1\").hex()\n'047f000001'\n>>> bytes(udp/9090).hex()\n          '91022382'\n>>> bytes(quic).hex()\n                  'cc03'\n>>> bytes(ma).hex()\n'047f00000191022382cc03'\n\nProtocol decapsulation by indexing and slicing:\n\n>>> ma[0]\nAddr('ip4', '127.0.0.1')\n>>> ma[:2]\nMultiaddr(Addr('ip4', '127.0.0.1'), Addr('udp', '9090'))\n>>> ma[1:]\nMultiaddr(Addr('udp', '9090'), Proto('quic'))\n\n\nAPI\n---\n\nFor the full API documentation, see https://multiformats.readthedocs.io/\n\nThe tables specifying all multicodecs and multibases known to this package are maintained as part of the `multiformats-config <https://github.com/hashberg-io/multiformats-config>`_ repository.\n\n\nContributing\n------------\n\nPlease see `<CONTRIBUTING.md>`_.\n\n\nLicense\n-------\n\n`MIT \u00a9 Hashberg Ltd. <LICENSE>`_\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Forked from the original author until they incorporate latest fixes; Python implementation of multiformats protocols.",
    "version": "0.2.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/hashberg-io/multiformats/issues",
        "Homepage": "https://github.com/hashberg-io/multiformats"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f458d3f506c292ff28a96659f71ea1b1996520969bfcb75f2567e651f2f0d4b",
                "md5": "93b0907ce3e58c7508ce807f7904d8a3",
                "sha256": "c29ff69fbcca838da109d78009b0b5550d5ba20951a34c7e4aa85fa31c3175d7"
            },
            "downloads": -1,
            "filename": "makkus.multiformats-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93b0907ce3e58c7508ce807f7904d8a3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 55824,
            "upload_time": "2023-11-28T09:47:47",
            "upload_time_iso_8601": "2023-11-28T09:47:47.402042Z",
            "url": "https://files.pythonhosted.org/packages/7f/45/8d3f506c292ff28a96659f71ea1b1996520969bfcb75f2567e651f2f0d4b/makkus.multiformats-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57b9333af4e9af51f97fce1cd0a43dc1c742c88505cc6cab2ed745ae4f8bb3d4",
                "md5": "e71ee61a46e1c8bf4ee6a05bd423d439",
                "sha256": "cb833864711031cdbad6e34057e2e3204d097e55c34eb18cc4be9f2c38feeddb"
            },
            "downloads": -1,
            "filename": "makkus.multiformats-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e71ee61a46e1c8bf4ee6a05bd423d439",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 87995,
            "upload_time": "2023-11-28T09:47:49",
            "upload_time_iso_8601": "2023-11-28T09:47:49.093989Z",
            "url": "https://files.pythonhosted.org/packages/57/b9/333af4e9af51f97fce1cd0a43dc1c742c88505cc6cab2ed745ae4f8bb3d4/makkus.multiformats-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-28 09:47:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hashberg-io",
    "github_project": "multiformats",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "makkus.multiformats"
}
        
Elapsed time: 0.15591s