variableNatEncode static method

List<int> variableNatEncode(
  1. BigInt val
)

Implementation

static List<int> variableNatEncode(BigInt val) {
  BigInt num = val & BigInt.from(mask32);
  List<int> output = [(num & BigInt.from(0xFF)).toInt() & 0x7F];
  num ~/= BigInt.from(128);
  while (num > BigInt.zero) {
    output.add(((num & BigInt.from(0xFF)).toInt() & 0x7F) | 0x80);
    num ~/= BigInt.from(128);
  }
  output = output.reversed.toList();
  return output;
}