decodeBigInt static method

BigInt decodeBigInt(
  1. Uint8List bytes
)

Given an ASN1 encoded integer return the integer value of the byte stream.

Implementation

static BigInt decodeBigInt(Uint8List bytes) {
  var isNegative = (bytes[0] & 0x80) != 0;
  var result = BigInt.zero;
  for (var i = 0; i < bytes.length; ++i) {
    result = result << 8;
    var x = isNegative ? (bytes[i] ^ 0xff) : bytes[i];
    result += BigInt.from(x);
  }
  if (isNegative) return (result + BigInt.one) * _minusOne;

  return result;
}