encodeBigInt function

Uint8List encodeBigInt(
  1. BigInt number
)

Encode a BigInt into bytes using big-endian encoding.

Implementation

Uint8List encodeBigInt(BigInt number) {
  // Not handling negative numbers. Decide how you want to do that.
  int size = (number.bitLength + 7) >> 3;
  var result = new Uint8List(size);
  for (int i = 0; i < size; i++) {
    result[size - i - 1] = (number & _byteMask).toInt();
    number = number >> 8;
  }
  return result;
}