getRandomValues function

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

Implementation

Uint8List getRandomValues([int length = _defaultLength]) {
  final DartRandom rn = DartRandom(math.Random.secure());
  String entropy = rn.nextBigInteger(length * 8).toRadixString(16);

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

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

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