13 lines
347 B
Dart
13 lines
347 B
Dart
|
|
import "dart:math";
|
||
|
|
|
||
|
|
String randomString(int length) {
|
||
|
|
const charset =
|
||
|
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||
|
|
final random = Random.secure();
|
||
|
|
final codeUnits = List<int>.generate(
|
||
|
|
length,
|
||
|
|
(index) => charset.codeUnitAt(random.nextInt(charset.length)),
|
||
|
|
);
|
||
|
|
return String.fromCharCodes(codeUnits);
|
||
|
|
}
|