--- id: asn1 version: "3.3.0" license: MIT license_treatment: permissive maintenance: active --- # asn1 — Python-ASN1 is a simple ASN.1 encoder and decoder for Python 2.7+ and 3.5+. License: permissive · Maintenance: active · Downloads: 1.7M/mo ## What it is and what it does Python-ASN1 is a pure-Python library for encoding and decoding ASN.1 data structures, the standard format used in cryptography, network protocols, and structured data interchange. It supports both BER (parser) and DER (parser and generator) encoding formats, including indefinite lengths, and handles most common ASN.1 types including REAL values. The library is designed to be lightweight and portable—it can be integrated by simply including a file in your project or installed via pip. The package provides two main interfaces: an Encoder class for converting Python data into ASN.1 binary format, and a Decoder class for parsing ASN.1 bytes back into readable values. Recent versions add context-manager support for cleaner resource handling and comply with ASN.1:2008 standards. It targets Python 2.7 and 3.5 through 3.14, relying only on enum-compat as a runtime dependency. Use it for: - Encode and decode structured data in network protocols that use ASN.1 serialization - Work with Object Identifiers (OIDs) and other ASN.1 primitives in protocol implementations - Integrate ASN.1 handling into legacy Python 2.7 systems without external C dependencies - Parse and generate ASN.1-encoded messages in compliance testing or protocol analysis - Build tools that transform ASN.1-encoded data across different encoding formats ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Encodes and decodes ASN.1 data structures using BER and DER formats, supporting most common ASN.1 types including REAL, with a pure-Python implementation. Yes. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and installs with minimal friction. It is suitable for any project needing ASN.1 encoding/decoding in pure Python across a wide range of Python versions. ## Install pip install asn1 uv add asn1 poetry add asn1 ## Installing asn1 Before you install: Low install friction with a single pure-Python runtime dependency (enum-compat). Actively maintained with a recent release and no known vulnerabilities. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations. Quickstart: pip install asn1 import asn1 encoder = asn1.Encoder() encoder.start() encoder.write('1.2.3', asn1.Numbers.ObjectIdentifier) encoded_bytes = encoder.output() decoder = asn1.Decoder() decoder.start(encoded_bytes) tag, value = decoder.read() Verify before relying: - Whether enum-compat is available for all supported Python versions (2.7, 3.5–3.14) - Performance characteristics when encoding/decoding large or deeply nested structures - Use in certificate and cryptographic applications beyond what the fact sheet documents ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 1.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags ASN.1 encoder decoder, BER DER encoding, ASN.1 serialization, binary data encoding, ASN.1 REAL type, object identifier encoding, ASN.1 parser, asn1-encoding, protocol-parsing, binary-serialization [View on SkillFed](https://skillfed.io/packages/asn1) · [View on PyPI](https://pypi.org/project/asn1/)