Skip to main content

Python-ASN1 is a simple ASN.1 encoder and decoder for Python 2.6+ and 3.3+.

Features

  • Support BER (parser) and DER (parser and generator) encoding

  • 100% python, compatible with version 2.6, 2.7, 3.3 and higher

  • Can be integrated by just including a file into your project

Dependencies

Python-ASN1 relies on Python-Future for Python 2 and 3 compatibility. To install Python-Future:

pip install future

How to install Python-asn1

Install from PyPi with the following:

pip install asn1

or download the repository from GitHub and install with the following:

python setup.py install

You can also simply include asn1.py into your project.

How to use Python-asn1

*Note: You can find an example in the examples directory in the repository.*

Encoding

If you want to encode data and retrieve its DER-encoded representation, use code such as:

import asn1

encoder = asn1.Encoder()
encoder.start()
encoder.write('1.2.3', asn1.ObjectIdentifier)
encoded_bytes = encoder.output()

Decoding

If you want to decode ASN.1 from DER or BER encoded bytes, use code such as:

import asn1

decoder = asn1.Decoder()
decoder.start(encoded_bytes)
tag, value = decoder.read()

Documentation

The complete documentation is available on Read The Docs:

python-asn1.readthedocs.io

License

Python-ASN1 is free software that is made available under the MIT license. Consult the file LICENSE that is distributed together with this file for the exact licensing terms.

Changelog

2.0.0b1 (2016-12-15)

  • First public release by Sebastien Andrivet

  • Support both python 2 and 3 (with Python-Future)

  • All strings are now in unicode

  • Add more ASN.1 tags (like PrintableString)

  • Fix errors in the example (dump.py)

  • Code reorganization

0.9 (2011-05-18)

  • Initial public release by Geert Jansen

Download files

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

Source Distribution

asn1-2.0.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

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

asn1-2.0.0-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file asn1-2.0.0.tar.gz.

File metadata

  • Download URL: asn1-2.0.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for asn1-2.0.0.tar.gz
Algorithm Hash digest
SHA256 fb5fcc5407b550859c71a571ae8057c2a1d5f64c1b26ef12faf603f296e3d012
MD5 457a8164fbc36c495018abe77a4a532e
BLAKE2b-256 df285e0cbd107e6342de4b818b2036313e12296c97e2df3cceb03ef6e1bec3a1

See more details on using hashes here.

File details

Details for the file asn1-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for asn1-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a6f7f11b1e4497fb33f3b5220ce12290c723bed3f5583b9f46bf527364f6ca48
MD5 39c95633496031257f90e67409056a15
BLAKE2b-256 ccd79928e515a81664497e6ed1d0ae0a576eca2c2865a4910b8ced39a502eab4

See more details on using hashes here.

Release history Release notifications | RSS feed

3.3.0

2 files

3.2.0

2 files

3.1.0

2 files

3.0.1

2 files

3.0.0

2 files

2.8.0

2 files

2.7.1

2 files

2.7.0

2 files

2.6.0

2 files

2.5.0

2 files

2.4.2

2 files

2.4.1

2 files

2.4.0

2 files

2.3.1

2 files

2.3.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

This release

2.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page