Skip to main content

A simple generic CBOR encoder / decoder

Project description

gencbor

This is a simple generic CBOR (RFC8949) encoder / decoder which will not look at any tag values.

How to use

>>> import gencbor
>>> gencbor.encode(gencbor.Tag(0x1001, [3, 4, 5]))
b'\xd9\x10\x01\x83\x03\x04\x05'
>>> gencbor.decode(b'\xd9\x10\x01\x83\x03\x04\x05')
Tag(4097, (3, 4, 5))
>>> gencbor.encode(gencbor.Map([(0, 'int'), (0.0, 'float')]))
b'\xa2\x00cint\xf9\x00\x00efloat'
>>> gencbor.decode(gencbor.encode(gencbor.Map([(0, 'int'), (0.0, 'float')])))
Map({0: int, 0.0: float})
>>> gencbor.decode(gencbor.encode([gencbor.SimpleValue(i) for i in range(18, 24)]))
(SimpleValue(18), SimpleValue(19), False, True, None, undefined)
>>> 

General

  • The library is will treat 0 and 0.0 as distinct, i.e. both values can be in keys in the same map.

  • The library is also supposed to treat different nan values as different, but currently there is a bug when encoding non-standard nan values.

  • The library will check for well-formed-ness and for basic validity. It will not check for tag validity.

  • false, true and null will by default be decoded to False, True and None.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gencbor-0.1.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gencbor-0.1.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file gencbor-0.1.2.tar.gz.

File metadata

  • Download URL: gencbor-0.1.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.2

File hashes

Hashes for gencbor-0.1.2.tar.gz
Algorithm Hash digest
SHA256 72df9b915ff1fc95365708941f42a655f9c45edb398dc669dbe0289dc87e9e5c
MD5 0894ed362374fe28c31aa041e6de9d35
BLAKE2b-256 034db026c3c3a72b2ecebf12b41eeeebb8b73791b78f423ce3314ab09a6c07b2

See more details on using hashes here.

File details

Details for the file gencbor-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gencbor-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.2

File hashes

Hashes for gencbor-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 224c3cbb2849d02d5326b881948b77a430778f6ef14e2b742452cc70db1e6b20
MD5 31c0fb0d4cae30aaf9b391281be9a3be
BLAKE2b-256 6676120b04ed7f2f5251a948163f1cc09d090bb84afcdb866a2f51b45412388d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page