@@ -7,33 +7,45 @@ import '../text/text.dart';
77/// eligible characters.
88///
99/// For a cryptographically secure random number, see [Rand.secure] .
10- class Rand with Text {
10+ class RandOf with Text {
1111 /// Texts of length [len] with randomly selected characters from [src] .
1212 ///
1313 /// [len] >= 0; src must not be empty.
1414 ///
15- /// For a cryptographically secure random number generator, see [Rand .secure] .
16- Rand ( int len, String src , [Random ? index])
15+ /// For a cryptographically secure random number generator, see [R .secure] .
16+ RandOf ( String src, int len , [Random ? index])
1717 : assert (len >= 0 , 'Error: negative length.' ),
1818 assert (src.isNotEmpty, 'Error: empty source of eligible characters.' ),
1919 _len = len,
2020 _src = src,
2121 _index = index ?? Random ();
2222
23- /// Cryptographically secure texts of length [len] with randomly selected
23+ /// Fixed-length texts with randomly selected digits [0–9] .
24+ ///
25+ /// This is the ideal class for generating verification codes.
26+ ///
27+ /// ```dart
28+ /// final fourDigitCode = RandOf.dig(4).value;
29+ /// ```
30+ RandOf .dig (int len, [Random ? index]) : this ('0123456789' , len, index);
31+
32+ /// Fixed-length strings with randomly selected hex digits [0–9a–f] .
33+ RandOf .hex (int len, [Random ? index]) : this ('0123456789abcdef' , len, index);
34+
35+ /// Cryptographically secure strings of length [len] with randomly selected
2436 /// characters from [src] .
2537 ///
2638 /// [len] >= 0; src must not be empty.
2739 ///
2840 /// It uses an instance of [Random.secure] as the index randomizer.
29- Rand .secure (int len, String src ) : this (len, src , Random .secure ());
41+ RandOf .secure (String src, int len ) : this (src, len , Random .secure ());
3042
31- final int _len;
3243 final String _src;
44+ final int _len;
3345 final Random _index;
3446
35- /// Generates fixed-length texts with randomly selected characters from the
36- /// source of eligible characters.
47+ /// Returns a fixed-length [String] with randomly selected characters from the
48+ /// predefined source of elegible characters.
3749 @override
3850 String call () {
3951 final Uint16List codes = Uint16List (_len);
0 commit comments