bytesToBigInt function

BigInt bytesToBigInt(
  1. Iterable<int> bytes, {
  2. Endian endian = Endian.big,
})

Decodes the provided BigInt from bytes. This is OS2IP as defined in rfc3447.

Implementation

BigInt bytesToBigInt(Iterable<int> bytes, {Endian endian = Endian.big}) {
  BigInt result = BigInt.from(0);
  if (endian == Endian.little) {
    bytes = bytes.toList().reversed;
  }

  for (int byte in bytes) {
    result = result << 8;
    result |= BigInt.from(byte);
  }

  return result;
}