Metadata-Version: 2.4
Name: larzcbor
Version: 0.1.0
Summary: CBOR (RFC 8949) encode/decode in pure Python - the IETF binary format (WebAuthn/COSE/IoT), with canonical map ordering. Zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzcbor
Project-URL: Repository, https://github.com/larz-scripter/larzcbor
Project-URL: Issues, https://github.com/larz-scripter/larzcbor/issues
Keywords: cbor,rfc8949,serialization,binary,encoding,webauthn,cose,iot,messagepack-alternative,zero-dependency
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
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](https://github.com/larz-scripter/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

```bash
pip install larzcbor
```

## Usage

```python
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](https://github.com/larz-scripter/larzpack) for MessagePack
compatibility; choose **larzcbor** when you need the IETF CBOR standard
(WebAuthn/COSE/IoT).

## Tests

```bash
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](https://github.com/larz-scripter).

## License

MIT © larz-scripter
