13 lines
270 B
Dart
13 lines
270 B
Dart
|
|
import 'dart:convert';
|
||
|
|
import 'dart:math';
|
||
|
|
|
||
|
|
class Secure {
|
||
|
|
static final Random _random = Random.secure();
|
||
|
|
|
||
|
|
static String token([int length = 32]) {
|
||
|
|
var values = List<int>.generate(length, (i) => _random.nextInt(256));
|
||
|
|
|
||
|
|
return base64Url.encode(values);
|
||
|
|
}
|
||
|
|
}
|