Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
Random Class Referencefinal

#include <Random.hpp>

Static Public Member Functions

template<typename T >
static std::enable_if< std::is_floating_point< T >::value, T >::type Real (const T min, const T max)
 Generates a random real between a range. More...
 
template<typename T >
static std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value, T >::type Int (const T min, const T max)
 Generates a random integer between a range. More...
 
static bool Bool (const double p=0.5)
 Generates a random boolean value. More...
 
static std::string Str (const std::size_t length) noexcept
 Generates a random string. More...
 
static std::vector< byte > Bytes (const std::size_t length) noexcept
 Generates a random vector of bytes. More...
 
static void Reseed ()
 

Detailed Description

Definition at line 12 of file Random.hpp.

Member Function Documentation

◆ Bool()

static bool Random::Bool ( const double  p = 0.5)
inlinestatic

Generates a random boolean value.

Parameters
pProbability of true (50% by default)
Returns
Returns a Random bool value, either 'true' or 'false'

Definition at line 49 of file Random.hpp.

◆ Bytes()

static std::vector<byte> Random::Bytes ( const std::size_t  length)
inlinestaticnoexcept

Generates a random vector of bytes.

Parameters
lengthlength of the random vector to generate
Returns
a random std::vector of bytes

Definition at line 90 of file Random.hpp.

◆ Int()

template<typename T >
static std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>::type Random::Int ( const T  min,
const T  max 
)
inlinestatic

Generates a random integer between a range.

Parameters
minminimum value of range (included in range)
maxmaximum value of range (included in range)
Returns
Random integer between min and max

Definition at line 38 of file Random.hpp.

◆ Real()

template<typename T >
static std::enable_if<std::is_floating_point<T>::value, T>::type Random::Real ( const T  min,
const T  max 
)
inlinestatic

Generates a random real between a range.

Parameters
minminimum value of range (included in range)
maxmaximum value of range (included in range)
Returns
Random real between min and max

Definition at line 24 of file Random.hpp.

◆ Reseed()

static void Random::Reseed ( )
inlinestatic

Reseeds the random engine with a new value

Definition at line 108 of file Random.hpp.

◆ Str()

static std::string Random::Str ( const std::size_t  length)
inlinestaticnoexcept

Generates a random string.

Parameters
lengthlength of the random string to generate
Returns
a random std::string a-zA-Z0-9

Definition at line 59 of file Random.hpp.


The documentation for this class was generated from the following file: