indutny / asn1.js

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

der: encode integers > 4294967295 and BigInts #113

Open jablko opened 5 years ago

jablko commented 5 years ago

Before

const INTEGER = asn1.define('INTEGER', function() {
  this.int();
});
console.log(INTEGER.decode(INTEGER.encode(0x100000000))); // <BN: 0>
console.log(INTEGER.decode(INTEGER.encode(1n))); // TypeError: num.toArray is not a function

After

console.log(INTEGER.decode(INTEGER.encode(0x100000000))); // <BN: 100000000>
console.log(INTEGER.decode(INTEGER.encode(1n))); // <BN: 1>