generateRandomBytes static method

Uint8List generateRandomBytes(
  1. int numBytes
)

Implementation

static Uint8List generateRandomBytes(int numBytes) {
  final secureRandom = FortunaRandom();

  final seedSource = Random.secure();
  final seeds = <int>[];
  for (int i = 0; i < 32; i++) {
    seeds.add(seedSource.nextInt(256));
  }
  secureRandom.seed(KeyParameter(Uint8List.fromList(seeds)));

  return secureRandom.nextBytes(numBytes);
}