Skip to main content

Pure Python X.690 implementation

Project description

Pure Python X.690 implementation

Build & Publish Docs

This module contains a pure Python implementation of the “x690” standard for BER encoding/decoding. Other encodings are currently unsupported but pull-requests are welcome.

Type Extensions

It allows defining and detecting new data-types by simply subclassing the base class x690.types.Type. An example for this can be seen in puresnmp

Examples

Encoding to bytes

Encoding to bytes can be done by simply calling the Python builting bytes() on instances from x690.types:

Encoding of a single value

import x690.types as t

>>> myvalue = t.Integer(12)
>>> asbytes = bytes(myvalue)
>>> repr(asbytes)
b'\x02\x01\x0c'

Encoding of a composite value using Sequence

import x690.types as t

>>> myvalue = t.Sequence(
...     t.Integer(12),
...     t.Integer(12),
...     t.Integer(12),
... )
>>> asbytes = bytes(myvalue)
>>> repr(asbytes)
b'0\t\x02\x01\x0c\x02\x01\x0c\x02\x01\x0c'

Decoding from bytes

Decode bytes by calling x690.types.pop_tlv on your byte data. This will return a tuple where the first value contains the decoded object, and the second one will contain any remaining bytes which were not decoded.

import x690.types as t
>>> data = b'0\t\x02\x01\x0c\x02\x01\x0c\x02\x01\x0c'
>>> decoded, remaining_bytes = t.pop_tlv(data)
>>> decoded
Sequence(Integer(12), Integer(12), Integer(12))
>>> remaining_bytes
b''

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

x690-0.2.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distributions

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

x690-0.2.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

x690-0.2.0-py2-none-any.whl (14.3 kB view details)

Uploaded Python 2

File details

Details for the file x690-0.2.0.tar.gz.

File metadata

  • Download URL: x690-0.2.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for x690-0.2.0.tar.gz
Algorithm Hash digest
SHA256 007e1beda9dd1663c144a8e023f2d1d342e5916d888bdc663418b60f5d9936c4
MD5 a19c8a0127506b92a69804be278134c7
BLAKE2b-256 ef31bc685d7fbfb85b88628be7fbe480aa1a202997b0d10d4ab8fcabb8d539aa

See more details on using hashes here.

File details

Details for the file x690-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: x690-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for x690-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68088d1ccd00dfbdb2ab87d8ab015e5d1d85f6f18c3dc29bb7e33ec0daec0d84
MD5 d98c8198d7e542c12f9a22fd46b41a0e
BLAKE2b-256 22401a2e63090302fac6daae178f8b376bba8655c691b84125588e032892bdb4

See more details on using hashes here.

File details

Details for the file x690-0.2.0-py2-none-any.whl.

File metadata

  • Download URL: x690-0.2.0-py2-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for x690-0.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 e1ae0720366d9effd0bf12fc7db1a46812bb44a13ef5f719ababd97f1a46717f
MD5 fa076c92360551abd58221f7a1f99f45
BLAKE2b-256 86c0149361e8c933ae343ffd53a9ab97edf7cfab992fe9ef9a63bc03e8fa1144

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