Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6
🏎️ Fast Python library to work with IPLD: DAG-CBOR, CID, CAR, multibase
License
NotificationsYou must be signed in to change notification settings
MarshalX/python-libipld
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This project aims to speed upThe AT Protocol SDK by using Rust for the heavy lifting. Only atproto related parts are implemented first.
Code snippet:
importlibipld# CIDprint(libipld.decode_cid('bafyreig7jbijxpn4lfhvnvyuwf5u5jyhd7begxwyiqe7ingwxycjdqjjoa'))# Output: {'hash': {'size': 32, 'code': 18, 'digest': b'\xdfHP\x9b\xbd\xbcYOV\xd7\x14\xb1{N\xa7\x07\x1f\xc2C^\xd8D\t\xf44\xd6\xbe\x04\x91\xc1)p'}, 'version': 1, 'codec': 113}print(libipld.encode_cid(b'\x01q\x12\xb6\x81\x1a\x1d\x7f\x8c\x17\x91\xdam\x1bO\x13m\xc0\xe2&y\xea\xfe\xaaX\xd6M~/\xaa\xd5\x89\x0e\x9d\x9c'))# Output: bafyreifwqenb274mc6i5u3i3j4jw3qhcez46v7vkldle27rpvlkysdu5tq# DAG-CBORprint(libipld.decode_dag_cbor(b'\xa2aa\x0cabfhello!'))# Output: {'a': 12, 'b': 'hello!'}print(libipld.encode_dag_cbor({'a':12,'b':'hello!'}))# Output: b'\xa2aa\x0cabfhello!'# multibaseprint(libipld.decode_multibase('ueWVzIG1hbmkgIQ'))# Output: ('u', b'yes mani !')print(libipld.encode_multibase('u',b'yes mani !'))# Output: ueWVzIG1hbmkgIQ
decode_cid(data: str | bytes) -> dict- Decode CIDs from string representation (e.g.,'bafy...') or raw bytes into structured data containing version, codec, and hash informationencode_cid(data: str | bytes) -> str- Encode CID raw bytes to string representation, or return string CIDs as-is
decode_dag_cbor(data: bytes) -> Any- Decode DAG-CBOR binary data into Python objects (dicts, lists, primitives)decode_dag_cbor_multi(data: bytes) -> list[Any]- Decode multiple concatenated DAG-CBOR objects from a single byte streamencode_dag_cbor(data: Any) -> bytes- Encode Python objects into DAG-CBOR binary format
decode_multibase(data: str) -> tuple[str, bytes]- Decode multibase-encoded strings, returning the base identifier and decoded dataencode_multibase(code: str, data: str | bytes) -> str- Encode data using specified multibase encoding (e.g., base58btc with code'u')
decode_car(data: bytes) -> tuple[dict, dict[bytes, dict]]- Decode CAR files into header metadata and a mapping of CID bytes to block data
- Python 3.8 or higher.
You can install or upgradelibipld via
pip install -U libipld
Contributions of all sizes are welcome.
MIT
About
🏎️ Fast Python library to work with IPLD: DAG-CBOR, CID, CAR, multibase
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.