generateRandomFromRng static method

BuBytes generateRandomFromRng({
  1. int length = 32,
  2. Rng? rng,
})

This function generates a random List<int> of the specified size (default is 32 bytes).

Implementation

static BuBytes generateRandomFromRng({int length = 32, Rng? rng}) {
  /// Generate the random bytes of the specified size using the _randomGenerator.
  final r = rng?.nextBytes(length) ?? _generateRandom(length);
  assert(r.length == length, "Incorrect random generted size.");

  /// Return the generated random bytes.
  return r;
}