SecureRandom.forTesting constructor
SecureRandom.forTesting({
- int seed = 0,
Returns a deterministic Random for testing purposes.
The sequence of outputs is a pure function of the seed
you give to the
constructor. In other words, this is only for meant for testing.
Example
import 'package:cryptography/cryptography.dart';
void main() {
final random = SecureRandom.forTesting(seed: 0);
final a = random.nextInt(1000);
final b = random.nextInt(1000);
final c = random.nextInt(1000);
print('$a, $b, $c');
// Always prints:
//
// 412, 913, 198
//
// Because it's a fake random number generator for testing only!
}
Implementation
factory SecureRandom.forTesting({
int seed = 0,
}) {
return _ChachaRandom.forTesting(seed: seed);
}