larzcbor
CBOR (RFC 8949) encode/decode. Pure Python, zero dependencies.
CBOR is the IETF's standard binary data format — compact like MessagePack, but an actual internet standard used by WebAuthn/FIDO2, COSE, and IoT (CoAP). larzcbor encodes and decodes the core data model with canonical map ordering.
from larzcbor import encode, decode
encode({"a": 1, "b": [2, 3]}) # b'\xa2aba\x01ab\x82\x02\x03'
decode(encode([1, "two", 3.0, {"x": True}]))
Why
- A standard, not a convention. CBOR is defined by RFC 8949; larzcbor is tested against the RFC's own byte vectors, so its output interoperates with every conformant CBOR tool and the systems that mandate it (WebAuthn attestation, COSE signing, CoAP payloads).
- Canonical output. Map keys are emitted in sorted byte order, so equal values encode to identical bytes — safe to hash or sign (pair with larzcrypt).
- Compact. Binary, with the same small-value efficiency as MessagePack; decodes float16/32/64 for full interop.
- Zero dependencies. No
cbor2, no C extension.
Install
pip install larzcbor
Usage
from larzcbor import encode, decode
blob = encode({"user": 42, "roles": ["admin"], "active": True})
decode(blob) # {'user': 42, 'roles': ['admin'], 'active': True}
Supports None, bool, int, float, str, bytes, list, dict.
larzcbor vs larzpack
Both are compact, canonical, zero-dep binary serializers. Choose larzpack for MessagePack compatibility; choose larzcbor when you need the IETF CBOR standard (WebAuthn/COSE/IoT).
Tests
python -m unittest discover -s tests -v # 16 tests incl. RFC 8949 vectors
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT © larz-scripter
Metadata
Release files for larzcbor 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larzcbor-0.1.0.tar.gz | 5.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzcbor-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / larzcbor-0.1.0.tar.gz
| Download URL | larzcbor-0.1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfcb6567441f12f2aee42053df9f391d18be0a8d81abbe8e507bc1e3b56d0d8a
|
|
BLAKE2b-256 checksum How to use checksums |
8cbacc2a359f78bc39ca60103d08c13815aa06c0e4f155ee6c6eb95a77fda226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzcbor-0.1.0-py3-none-any.whl
| Download URL | larzcbor-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ea09e1482978d00603609fb9bbec471e8d263e16c457ce1dee0fb3031b8dc2d
|
|
BLAKE2b-256 checksum How to use checksums |
3231f53035828ed608c228fa9967d673ababb3add426d8491548e99ca79710d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzcbor 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.