skip to navigation
skip to content

asn1 2.2.0

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

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


  • 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


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 install

You can also simply include into your project.

How to use Python-asn1


You can find more detailed documentation on the Usage page.


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

import asn1

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


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

import asn1

decoder = asn1.Decoder()
tag, value =


The complete documentation is available on Read The Docs:


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


2.1.1 (2017-10-30)

  • Fix a bug (#9): two’s complement corner case with values such as -32769. Add new test cases to test them.

2.1.0 (2016-12-18)

  • Add more documentation
  • Use (simulated) enumerations
  • Add Python 2.6 in automated checks and tests
  • Add type hints (for static checking) and fix some code

2.0.0 (2016-12-16)

  • 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 (
  • Code reorganization

0.9 (2011-05-18)

  • Initial public release by Geert Jansen
File Type Py Version Uploaded on Size
asn1-2.2.0-py2.py3-none-any.whl (md5) Python Wheel 3.6 2017-10-30 9KB
asn1-2.2.0.tar.gz (md5) Source 2017-10-30 30KB