getRandomValues function

Uint8List getRandomValues([
  1. int length = DEFAULT_LENGTH
])

Implementation

Uint8List getRandomValues([int length = DEFAULT_LENGTH]) {
  DartRandom rn = DartRandom(Random.secure());
  var entropy = rn.nextBigInteger(length * 8).toRadixString(16);

  if (entropy.length > length * 2) {
    entropy = entropy.substring(0, length * 2);
  }

  var randomPers = rn.nextBigInteger((length) * 8).toRadixString(16);

  if (randomPers.length > (length) * 2) {
    randomPers = randomPers.substring(0, (length) * 2);
  }
  return randomPers.toU8a();
}