fillBytes function

List<int> fillBytes(
  1. BigInt v,
  2. int len
)

Implementation

List<int> fillBytes(BigInt v, int len) {
  List<int> result = List.filled(len, 0);
  int bytes = (v.bitLength + 7) >> 3;
  var b256 = BigInt.from(256);
  var offset = len - 1;
  for (int i = 0; i < bytes; i++) {
    result[offset] = v.remainder(b256).toInt();
    v = v >> 8;
    offset--;
  }
  return result;
}