Skip to content

Commit 966d9ed

Browse files
Dillon Nysdnys1
authored andcommitted
chore(aws_common): Add secure uuid flag
1 parent b699c30 commit 966d9ed

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/aws_common/lib/src/util/uuid.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
import 'package:uuid/uuid.dart';
1616
import 'package:uuid/uuid_util.dart';
1717

18-
/// Generates a crypto-secure UUID (v4).
19-
String uuid() => const Uuid().v4(
20-
// Use the crypto-secure RNG per `package:uuid` docs:
21-
// https://github.com/Daegalus/dart-uuid/blob/d7bc930942afc752edd0fd15f8bf8234d81dfeda/example/example.dart#L21
22-
options: const <String, Object>{
23-
'rng': UuidUtil.cryptoRNG,
24-
},
18+
/// Generates a UUID (v4).
19+
///
20+
/// If [secure] is `true`, uses a crypto-secure RNG at the cost of worse
21+
/// performance (5-100x, depending on the platform).
22+
String uuid({bool secure = false}) => const Uuid().v4(
23+
options: !secure
24+
? null
25+
// Use the crypto-secure RNG per `package:uuid` docs:
26+
// https://github.com/Daegalus/dart-uuid/blob/d7bc930942afc752edd0fd15f8bf8234d81dfeda/example/example.dart#L21
27+
: const <String, Object>{
28+
'rng': UuidUtil.cryptoRNG,
29+
},
2530
);

0 commit comments

Comments
 (0)