I am new to asn1 ,my agenda is i want to convert python dictionary into .asn format. when i ran the below code i got the following error
ParseError: Invalid ASN.1 syntax at line 1, column 1: '>!<"': Expected modulereference.
from __future__ import print_function
from binascii import hexlify
import asn1tools
specification=""""
Foo DEFINITIONS ::= BEGIN
Question ::= SEQUENCE {
id INTEGER,
question IA5String
}
Answer ::= SEQUENCE {
id INTEGER,
answer BOOLEAN
}
END
""""
Foo = asn1tools.compile_string(specification, 'uper')
Question = {'id': 2, 'question': u'Hi how r u?!'}
Answer ={'id': 2, 'answer': u'Hi i am good'}
encoded = Foo.encode('Question', Question)
encoded1 = Foo.encode('Answer', Answer)
decoded = Foo.decode('Question', Question)
print('Question:', Question)
print('Encoded:', hexlify(encoded).decode('ascii'))
print('Decoded:', decoded)
Your ASN.1 schema looks correct. You can validate the syntax at asn1.io. Since the error is reported to be the first character (line 1, column 1) it might be an extra quote or some other char that gets inserted when you prepare the specification..