beInt2Buff static method

Uint8List beInt2Buff(
  1. BigInt n,
  2. int len
)

Implementation

static Uint8List beInt2Buff(BigInt n, int len) {
  BigInt r = n;
  int o = len - 1;
  final buff = Uint8List(len);
  while ((r > BigInt.zero) && (o >= 0)) {
    final c = (r & BigInt.from(255)).toInt();
    buff[o] = c;
    o--;
    r = r >> 8;
  }
  if (r != BigInt.zero) {
    throw new ArgumentError("Number does not fit in this length");
  }
  return buff;
}