On Sun, 7 May 2023 08:46:26 -0400 Robert Moskowitz rgm@htt-consult.com wrote:
from /usr/share/doc/python3-asn1/README.rst of the fedora package python3-asn1
How to use Python-asn1 ======================
.. note:: You can find more detailed documentation on the `Usage`_ page.
.. _Usage: usage.rst
Encoding --------
If you want to encode data and retrieve its DER-encoded representation, use code such as:
.. code-block:: python
import asn1
encoder = asn1.Encoder() encoder.start() encoder.write('1.2.3', asn1.Numbers.ObjectIdentifier) encoded_bytes = encoder.output()
Decoding --------
If you want to decode ASN.1 from DER or BER encoded bytes, use code such as:
.. code-block:: python
import asn1
decoder = asn1.Decoder() decoder.start(encoded_bytes) tag, value = decoder.read()