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) {
  var buffer = new Uint8List(length);
  var rng = new Random.secure();
  for (var i = 0; i < length; i++) {
    buffer[i] = rng.nextInt(256);
  }

  return buffer;
}