indutny / asn1.js

ASN.1 Decoder/Encoder/DSL
MIT License
181 stars 64 forks source link

How to use choice #138

Open koshi148 opened 1 year ago

koshi148 commented 1 year ago

I don't know how to use choice tag. The code below gives me an error and I can't encode it.

const asn1 = require('asn1.js');
const Message = asn1.define('Message', function () {
    this.choice({
        aaa: this.utf8str()
    })
});
const encoded = Message.encode({
        aaa: '5'    
}, 'der');
console.log(encoded);

So I need a simple example.