GitHub - multiformats/py-multicodec: Multicodec implementation in Python (original) (raw)

This project is no longer maintained and has been archived.

py-multicodec

https://img.shields.io/travis/multiformats/py-multicodec.svg?branch=master Documentation Status

Multicodec implementation in Python

multicodec is a self-describing multiformat, it wraps other formats with a tiny bit of self-description.

A multicodec identifier is both a varint and the code identifying the following data, this means that the most significant bit of every multicodec code is reserved to signal the continuation.

You can check the table here for the list of supported codecs by py-multicodec.

Installation

$ pip install py-multicodec

Sample Usage

from multicodec import add_prefix, remove_prefix, get_codec

adding a prefix to existing data

add_prefix('sha2-256', b'EiC5TSe5k00') b'\x12EiC5TSe5k00'

removing prefix from prefixed data

remove_prefix(b'\x12EiC5TSe5k00') EiC5TSe5k00

get codec used to prefix the prefixed data

get_codec(b'\x12EiC5TSe5k00') 'sha2-256'

Updating the lookup table

Updating the lookup table is done with a script. The source of truth is themulticodec default table. Update the table with running:

$ curl -X GET https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv | ./tools/update-table.py