leInt2Buff static method

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

Implementation

static Uint8List leInt2Buff(BigInt n, int len) {
  BigInt r = n;
  int o = 0;

  final buff = Uint8List(len);
  while ((r > BigInt.zero) && (o < buff.length)) {
    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;
}