generate static method

List<int> generate(
  1. int length
)

Generates a random salt of length bytes from a cryptographically secure random number generator.

Each element of this list is a byte.

Implementation

static List<int> generate(int length) {
  final Uint8List buffer = Uint8List(length);
  final Random rng = Random.secure();
  for (int i = 0; i < length; i++) {
    buffer[i] = rng.nextInt(256);
  }
  return buffer;
}