Skip to content

Commit ebf6b3a

Browse files
Rexios80daegalus
authored andcommitted
Always use secure random as a default
1 parent 65979d4 commit ebf6b3a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lib/data.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:uuid/rng.dart';
22

33
/// [GlobalOptions] stores the global options passed into the library on instantiation.
4-
/// [GlobalOptions.rng] is the random number generator class to use. Defaults to MathRNG() [MathRNG]
4+
/// [GlobalOptions.rng] is the random number generator class to use. Defaults to CryptoRNG() [CryptoRNG]
55
class GlobalOptions {
66
final RNG? rng;
77

@@ -32,7 +32,7 @@ class V1Options {
3232
/// [V4Options] stores the options passed into the v4 function.
3333
/// [random] is the random bytes to use to generate the UUID. Primarily used for
3434
/// testing, or recreating a UUID
35-
/// [rng] is the random number generator function to use. Defaults to MathRNG() [MathRNG]
35+
/// [rng] is the random number generator function to use. Defaults to CryptoRNG() [CryptoRNG]
3636
class V4Options {
3737
final List<int>? random;
3838
final RNG? rng;
@@ -116,7 +116,7 @@ class V1State {
116116
static int? clockSeq = 0;
117117
static int mSecs = 0;
118118
static int nSecs = 0;
119-
static RNG random = MathRNG();
119+
static RNG random = CryptoRNG();
120120
static bool initialized = false;
121121
}
122122

@@ -126,7 +126,7 @@ class V1State {
126126
/// initialized once already. Prevents re-initialization on subsequent calls to
127127
/// _init() from within the v4 function.
128128
class V4State {
129-
static RNG random = MathRNG();
129+
static RNG random = CryptoRNG();
130130
static bool initialized = true;
131131
}
132132

@@ -143,7 +143,7 @@ class V6State {
143143
static int? clockSeq;
144144
static int mSecs = 0;
145145
static int nSecs = 0;
146-
static RNG random = MathRNG();
146+
static RNG random = CryptoRNG();
147147
static bool initialized = false;
148148
}
149149

@@ -153,7 +153,7 @@ class V6State {
153153
/// initialized once already. Prevents re-initialization on subsequent calls to
154154
/// _init() from within the v4 function.
155155
class V7State {
156-
static RNG random = MathRNG();
156+
static RNG random = CryptoRNG();
157157
static bool initialized = true;
158158
}
159159

@@ -163,6 +163,6 @@ class V7State {
163163
/// initialized once already. Prevents re-initialization on subsequent calls to
164164
/// _init() from within the v4 function.
165165
class V8State {
166-
static RNG random = MathRNG();
166+
static RNG random = CryptoRNG();
167167
static bool initialized = true;
168168
}

lib/uuid.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class Uuid {
4848
/// for all UUID generation.
4949
/// [GlobalOptions.rng] is a [RNG] class that returns a list of random bytes.
5050
///
51-
/// Defaults rng function is `UuidUtil.mathRNG`
51+
/// Defaults rng function is `UuidUtil.cryptoRNG`
5252
///
53-
/// Example: Using CryptoRNG globally
53+
/// Example: Using MathRNG globally
5454
///
5555
/// ```dart
5656
/// var uuid = Uuid(options: {
57-
/// 'grng': UuidUtil.cryptoRNG
57+
/// 'grng': UuidUtil.mathRNG
5858
/// })
5959
///
6060
/// // Generate a v4 (random) id that will use cryptRNG for its rng function
@@ -244,7 +244,7 @@ class Uuid {
244244

245245
/// Generates a RNG version 4 UUID
246246
///
247-
/// By default it will generate a string based mathRNG, and will return
247+
/// By default it will generate a string based cryptoRNG, and will return
248248
/// a string. If you wish to use crypto-strong RNG, pass in UuidUtil.cryptoRNG
249249
///
250250
/// The first argument is an options map that takes various configuration
@@ -315,7 +315,7 @@ class Uuid {
315315

316316
/// Generates a RNG version 4 UUID into a provided buffer
317317
///
318-
/// By default it will generate a string based off mathRNG, and will
318+
/// By default it will generate a string based off cryptoRNG, and will
319319
/// place the result into the provided [buffer]. The [buffer] will also be returned.
320320
/// If you wish to have crypto-strong RNG, pass in UuidUtil.cryptoRNG.
321321
///
@@ -349,7 +349,7 @@ class Uuid {
349349

350350
/// Generates a RNG version 4 UUID as a [UuidValue] object
351351
///
352-
/// By default it will generate a string based mathRNG, and will return
352+
/// By default it will generate a string based cryptoRNG, and will return
353353
/// a [UuidValue] object. If you wish to use crypto-strong RNG, pass in UuidUtil.cryptoRNG
354354
///
355355
/// The first argument is an options map that takes various configuration

lib/v4.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class UuidV4 {
88

99
/// v4() Generates a RNG version 4 UUID
1010
///
11-
/// By default it will generate a string based mathRNG, and will return
11+
/// By default it will generate a string based cryptoRNG, and will return
1212
/// a string. If you wish to use crypto-strong RNG, pass in UuidUtil.cryptoRNG
1313
///
1414
/// The first argument is an options map that takes various configuration

0 commit comments

Comments
 (0)