getRandomBytes function

Uint8List getRandomBytes(
  1. int length
)

Generates a list of random bytes of the specified length.

length The desired length of the byte list.

Returns a Uint8List containing cryptographically secure random bytes.

Implementation

Uint8List getRandomBytes(int length) {
  final r = Uint8List(length);
  for (var i = 0; i < length; i++) {
    r[i] = _random.nextInt(255);
  }
  return r;
}