generateRandom function
Generates a random Uint8List of the specified size
.
This function generates a random Uint8List of the specified size
using
the Fortuna cryptographic random number generator. If the _randomGenerator
instance is not yet initialized, it is seeded with platform entropy.
Returns a Uint8List containing random bytes of the specified size
.
Implementation
Uint8List generateRandom(int size) {
if (_randomGenerator == null) {
_randomGenerator = FortunaRandom();
_randomGenerator!.seed(KeyParameter(
platform.Platform.instance.platformEntropySource().getBytes(32)));
}
final randomBytes = _randomGenerator!.nextBytes(size);
return randomBytes;
}