Random Classes
The MAXON API provides pseudo random number generators for trivial purposes and cryptographic applications.
maxon::LinearCongruentialRandom is a standard pseudo random number generator that can be initialized with a seed value:
// prepare array maxon::BaseArray<maxon::Float32> values; 值。 EnsureCapacity (count) iferr_return ;
// init pseudo random generator maxon::LinearCongruentialRandom<maxon::Float32> random; random. Init (123);
// fill array with random float values for ( maxon::Int32 i = 0; i < count; ++i) { const maxon::Float32 randomValue = random. Get01 (); 值。 Append (randomValue) iferr_return ; }
maxon::SecureRandom is a cryptographically secure pseudo-random number generator. It is typically used in the context of encrypting data. See Cryptography
maxon::SecureRandom provides these static functions:
// prepare array maxon::BaseArray<maxon::UChar> values; 值。 Resize (100) iferr_return ;
// fill array with random data const maxon::SecureRandomProvider provider = maxon::SecureRandom::GetDefaultProvider (); maxon::SecureRandom::GetRandomNumber (provider, values);
// print random data for ( maxon::UChar & chr : values) { DiagnosticOutput ( "Random Data: @" , chr); }