11 lines
306 B
Dart
11 lines
306 B
Dart
import 'dart:math';
|
|
|
|
/// Random hex id from a cryptographic RNG, e.g. for per-install identifiers.
|
|
String randomHexId({int bytes = 16}) {
|
|
final random = Random.secure();
|
|
return List<int>.generate(
|
|
bytes,
|
|
(_) => random.nextInt(256),
|
|
).map((b) => b.toRadixString(16).padLeft(2, '0')).join();
|
|
}
|