generateRandom function
This function generates a random Uint8List of the specified size (default is 32 bytes).
Implementation
Uint8List generateRandom({int size = 32}) {
/// Check if the _randomGenerator instance has been initialized.
if (_randomGenerator == null) {
/// If not, create a new FortunaRandom instance and seed it with entropy.
_randomGenerator = FortunaRandom();
/// Generate 32 bytes of entropy from the platform's entropy source and use it as the seed.
_randomGenerator!.seed(KeyParameter(
platform.Platform.instance.platformEntropySource().getBytes(32)));
}
/// Generate the random bytes of the specified size using the _randomGenerator.
final r = _randomGenerator!.nextBytes(size);
/// Return the generated random bytes.
return r;
}