JonathanWilbur / asn1-ts

ASN.1 TypeScript library, including codecs for Basic Encoding Rules (BER) and Distinguished Encoding Rules (DER).
MIT License
32 stars 6 forks source link

How to get updated ber? #31

Open ayZagen opened 4 months ago

ayZagen commented 4 months ago

I am trying to update a value from the decoded ber element. Here is quick snippet (npm RunKit):

const ber = new asn.BERElement();

ber.fromBytes( new Uint8Array( [ 48,12,2,1,1,96,7,2,1,3,4,0,128,0 ] ) );

ber.components[0].integer = ber.sequence[0].integer = 5;

const newBytes = ber.toBytes();

console.assert( ber.components[0].integer === 5 );
console.assert( ber.sequence[0].integer === 5 );
console.assert( newBytes[4] === 5 );

All assertions fail.

How can I update a value and get the final updated structure?