genFortuna method

String genFortuna({
  1. int len = 32,
})

Generate cryptographically-secure random string using Fortuna algorithm. The string is encoded using base64. Thus, this is for use with encoded classes.

This should be used for all cases where randomness is of high importance. This includes, but is not limited to, key generation.

Defaults to length 32 bytes.

Implementation

String genFortuna({int len = 32}) {
  rand ??= _getFortunaRandom();
  var values = rand!.nextBytes(len);
  var stringer = base64.encode(values);
  return stringer;
}