platform/packages/cli/lib/src/random_string.dart

16 lines
362 B
Dart
Raw Normal View History

2018-07-14 22:47:24 +00:00
import 'dart:math';
const String _valid =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
final Random _rnd = new Random.secure();
String randomAlphaNumeric(int length) {
var b = new StringBuffer();
for (int i = 0; i < length; i++) {
b.writeCharCode(_valid.codeUnitAt(_rnd.nextInt(_valid.length)));
}
return b.toString();
}