asn.1 parser in C/Python

后端 未结 7 2188
借酒劲吻你
借酒劲吻你 2021-02-02 00:41

I am looking for a solution to parse asn.1 spec files and generate a decoder from those.

Ideally I would like to work with Python modules, but if nothing is available I

7条回答
  •  忘了有多久
    2021-02-02 01:15

    I recently created the Python package called asn1tools which compiles an ASN.1 specification into Python objects, which can be used to encode and decode messages.

    >>> import asn1tools
    >>> foo = asn1tools.compile_file('tests/files/foo.asn')
    >>> encoded = foo.encode('Question', {'id': 1, 'question': 'Is 1+1=3?'})
    >>> encoded
    bytearray(b'0\x0e\x02\x01\x01\x16\x09Is 1+1=3?')
    >>> foo.decode('Question', encoded)
    {'id': 1, 'question': 'Is 1+1=3?'}
    

提交回复
热议问题