Skip to content

Commit

Permalink
Always use secure random as a default
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 authored and daegalus committed Aug 30, 2024
1 parent 65979d4 commit ebf6b3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions lib/data.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:uuid/rng.dart';

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

Expand Down Expand Up @@ -32,7 +32,7 @@ class V1Options {
/// [V4Options] stores the options passed into the v4 function.
/// [random] is the random bytes to use to generate the UUID. Primarily used for
/// testing, or recreating a UUID
/// [rng] is the random number generator function to use. Defaults to MathRNG() [MathRNG]
/// [rng] is the random number generator function to use. Defaults to CryptoRNG() [CryptoRNG]
class V4Options {
final List<int>? random;
final RNG? rng;
Expand Down Expand Up @@ -116,7 +116,7 @@ class V1State {
static int? clockSeq = 0;
static int mSecs = 0;
static int nSecs = 0;
static RNG random = MathRNG();
static RNG random = CryptoRNG();
static bool initialized = false;
}

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

Expand All @@ -143,7 +143,7 @@ class V6State {
static int? clockSeq;
static int mSecs = 0;
static int nSecs = 0;
static RNG random = MathRNG();
static RNG random = CryptoRNG();
static bool initialized = false;
}

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

Expand All @@ -163,6 +163,6 @@ class V7State {
/// initialized once already. Prevents re-initialization on subsequent calls to
/// _init() from within the v4 function.
class V8State {
static RNG random = MathRNG();
static RNG random = CryptoRNG();
static bool initialized = true;
}
12 changes: 6 additions & 6 deletions lib/uuid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class Uuid {
/// for all UUID generation.
/// [GlobalOptions.rng] is a [RNG] class that returns a list of random bytes.
///
/// Defaults rng function is `UuidUtil.mathRNG`
/// Defaults rng function is `UuidUtil.cryptoRNG`
///
/// Example: Using CryptoRNG globally
/// Example: Using MathRNG globally
///
/// ```dart
/// var uuid = Uuid(options: {
/// 'grng': UuidUtil.cryptoRNG
/// 'grng': UuidUtil.mathRNG
/// })
///
/// // Generate a v4 (random) id that will use cryptRNG for its rng function
Expand Down Expand Up @@ -244,7 +244,7 @@ class Uuid {

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

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

/// Generates a RNG version 4 UUID as a [UuidValue] object
///
/// By default it will generate a string based mathRNG, and will return
/// By default it will generate a string based cryptoRNG, and will return
/// a [UuidValue] object. If you wish to use crypto-strong RNG, pass in UuidUtil.cryptoRNG
///
/// The first argument is an options map that takes various configuration
Expand Down
2 changes: 1 addition & 1 deletion lib/v4.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UuidV4 {

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

0 comments on commit ebf6b3a

Please sign in to comment.