genDartRaw method

Uint8List genDartRaw({
  1. int len = 16,
})

Generate cryptographically-secure random string using Dart math.random. The string is not encoded and returned as a Uint8List. Thus, this is for use with raw classes.

This is less secure than Fortuna, but faster. It can be used for IVs and salts, but never for keys.

Defaults to length 16 bytes.

Implementation

Uint8List genDartRaw({int len = 16}) {
  dart ??= Random.secure();
  return Uint8List.fromList(List.generate(len, (i) => dart!.nextInt(256)));
}