Abstract base class for PRNG's (pseudo-random numbers generators).
More...
#include <tsRandomGenerator.h>
|
virtual | ~RandomGenerator () |
| Virtual destructor.
|
|
virtual UString | name () const =0 |
| Algorithm name (informational only).
|
|
virtual bool | read (void *addr, size_t size)=0 |
| Get random data.
|
|
virtual bool | readByteBlock (ByteBlock &data, size_t size) |
| Get random data in a byte block.
|
|
template<typename INT_T , typename std::enable_if< std::is_integral< INT_T >::value >::type * = nullptr> |
bool | readInt (INT_T &value, INT_T min=std::numeric_limits< INT_T >::min(), INT_T max=std::numeric_limits< INT_T >::max()) |
| Get a random integer value inside a defined range.
|
|
virtual bool | ready () const =0 |
| Check if the PRNG is ready.
|
|
virtual bool | seed (const void *addr, size_t size)=0 |
| Seed (add entropy) to the PRNG.
|
|
Abstract base class for PRNG's (pseudo-random numbers generators).
◆ name()
virtual UString ts::RandomGenerator::name |
( |
| ) |
const |
|
pure virtual |
◆ seed()
virtual bool ts::RandomGenerator::seed |
( |
const void * |
addr, |
|
|
size_t |
size |
|
) |
| |
|
pure virtual |
Seed (add entropy) to the PRNG.
- Parameters
-
[in] | addr | Address of entropy data. |
[in] | size | Size in bytes of entropy data. |
- Returns
- True on success, false on error.
Implemented in ts::SystemRandomGenerator, and ts::Xoshiro256ss.
◆ ready()
virtual bool ts::RandomGenerator::ready |
( |
| ) |
const |
|
pure virtual |
◆ read()
virtual bool ts::RandomGenerator::read |
( |
void * |
addr, |
|
|
size_t |
size |
|
) |
| |
|
pure virtual |
◆ readByteBlock()
virtual bool ts::RandomGenerator::readByteBlock |
( |
ByteBlock & |
data, |
|
|
size_t |
size |
|
) |
| |
|
virtual |
Get random data in a byte block.
The default implementation uses read().
- Parameters
-
[out] | data | Returned random data. |
[in] | size | Requested size in bytes of random data. |
- Returns
- True on success, false on error.
◆ readInt()
template<typename INT_T , typename std::enable_if< std::is_integral< INT_T >::value >::type * >
bool ts::RandomGenerator::readInt |
( |
INT_T & |
value, |
|
|
INT_T |
min = std::numeric_limits<INT_T>::min() , |
|
|
INT_T |
max = std::numeric_limits<INT_T>::max() |
|
) |
| |
Get a random integer value inside a defined range.
- Template Parameters
-
INT_T | An integer type for the result. |
- Parameters
-
[out] | value | The return integer value. |
[in] | min | Minimum value to return. |
[in] | max | Maximum value to return. |
- Returns
- True on success, false on error.
The documentation for this class was generated from the following file: