hash_U64 function

Uint8List hash_U64(
  1. BigInt n
)

@param {BigInt} n @returns {Buffer}

Implementation

// ignore: non_constant_identifier_names
Uint8List hash_U64(BigInt n) {
  // const buf = Buffer.allocUnsafe(10);
  var buf = Uint8List(10);
  var i = 0;
  while (true) {
    var byte = (n & BigInt.from(0x7f));
    n >>= BigInt.from(7).toInt();
    if (n == BigInt.zero) {
      buf[i] = byte.toInt();
      break;
    } else {
      buf[i] = byte.toInt() | 0x80;
      ++i;
    }
  }
  return hash_bytes(buf.sublist(0, i + 1));
}