Protocol++® (Protocolpp®)  v5.6.2
ProtocolPP::jrand Class Reference

Public Member Functions

 jrand ()
 
 jrand (uint64_t myseed, bool use_crypto=false)
 
virtual ~jrand ()=default
 Standard deconstructor.
 
bool getbool ()
 
std::string getname (uint32_t length)
 
std::string getstr (const char *input)
 
jarray< char > getchar (uint32_t amount)
 
jarray< uint8_t > getbyte (uint32_t amount, bool use_crypto=false)
 
jarray< uint8_t > getbyte (const char *range, uint32_t mult=0, bool use_crypto=false)
 
jarray< uint16_t > getu16 (uint32_t amount, bool use_crypto=false)
 
jarray< uint16_t > getu16 (const char *range, bool use_crypto=false)
 
jarray< uint32_t > getword (uint32_t amount, bool use_crypto=false)
 
jarray< uint32_t > getword (const char *range, bool use_crypto=false)
 
jarray< uint64_t > getdouble (uint32_t amount, bool use_crypto=false)
 
jarray< uint64_t > getdouble (const char *range, bool use_crypto=false)
 
int get_int (bool use_crypto=false)
 
int get_int (const char *range, bool use_crypto=false)
 
uint32_t get_uint (const char *range, bool use_crypto=false)
 
uint8_t get_u8 (bool use_crypto=false)
 
uint16_t get_u16 (bool use_crypto=false)
 
uint32_t get_u32 (bool use_crypto=false)
 
uint64_t get_u64 (bool use_crypto=false)
 
void seed (uint64_t myseed)
 
void seed (std::seed_seq &myseed)
 
void seed_crypto ()
 Method to reseed crypto generator from hardware.
 
jarray< uint8_t > get_crypto (uint32_t size)
 
 jrand (jrand &rhs)=delete
 
 jrand (const jrand &rhs)=delete
 

Static Public Member Functions

static std::vector< std::string > tokenizer (const char *input, const char *delimiters)
 

Constructor & Destructor Documentation

◆ jrand() [1/2]

ProtocolPP::jrand::jrand ( )

Standard constructor for the jrand class. Seeded with 0x5489UL, RandomPool seeded from hardware global use_crypto is set to false (use_crypto can be set on a function by function basis)

◆ jrand() [2/2]

ProtocolPP::jrand::jrand ( uint64_t  myseed,
bool  use_crypto = false 
)
explicit

Constructor for jrand that accepts an uint64_t for the seed

Parameters
myseed- seed to initialize psuedo-random number generator
use_crypto- Use cryptographic quality random numbers Sets use in the randomizer globally, overrides use_crytpo in individual functions if set to true

Member Function Documentation

◆ get_crypto()

jarray<uint8_t> ProtocolPP::jrand::get_crypto ( uint32_t  size)

Method to obtain cryptographic random data to be used for keys, salt, IV

Parameters
size- length of cryptographic data
Returns
array filled with hardware generated random numbers that are non-reproducible

◆ get_int() [1/2]

int ProtocolPP::jrand::get_int ( bool  use_crypto = false)

Method to obtain a single random integer from the random number generator

Parameters
use_crypto- Uses hardware generated random values, non-reproducible
Returns
integer

◆ get_int() [2/2]

int ProtocolPP::jrand::get_int ( const char *  range,
bool  use_crypto = false 
)

Method to obtain a single random integer from the random number generator

Parameters
rangeRange of integers to randomize over. Can either be of the form "1..32" or "16:32:64"
use_crypto- Uses hardware generated random values, non-reproducible
Returns
integer

◆ get_u16()

uint16_t ProtocolPP::jrand::get_u16 ( bool  use_crypto = false)

Method to obtain a single random uint16_t from the random number generator

Parameters
use_crypto- Uses hardware generated random values, non-reproducible
Returns
uint16_t

◆ get_u32()

uint32_t ProtocolPP::jrand::get_u32 ( bool  use_crypto = false)

Method to obtain a single random uint32_t from the random number generator

Parameters
use_crypto- Uses hardware generated random values, non-reproducible
Returns
uint32_t

◆ get_u64()

uint64_t ProtocolPP::jrand::get_u64 ( bool  use_crypto = false)

Method to obtain a single random uint64_t from the random number generator

Parameters
use_crypto- Uses hardware generated random values, non-reproducible
Returns
uint64_t

◆ get_u8()

uint8_t ProtocolPP::jrand::get_u8 ( bool  use_crypto = false)

Method to obtain a single random byte from the random number generator

Parameters
use_crypto- Uses hardware generated random values, non-reproducible
Returns
uint8_t

◆ get_uint()

uint32_t ProtocolPP::jrand::get_uint ( const char *  range,
bool  use_crypto = false 
)

Method to obtain a single random uint32_teger from the random number generator

Parameters
rangeRange of integers to randomize over. Can either be of the form "1..32" or "16:32:64"
use_crypto- Uses hardware generated random values, non-reproducible
Returns
integer

◆ getbool()

bool ProtocolPP::jrand::getbool ( )

Method to obtain a random boolean from the random number generator

Returns
randomly choosen True or False

◆ getbyte() [1/2]

jarray<uint8_t> ProtocolPP::jrand::getbyte ( const char *  range,
uint32_t  mult = 0,
bool  use_crypto = false 
)

Method to obtain an array of bytes from the random number generator

Parameters
range- String representing a range of sizes ex., "1..256"
mult- Round the length of the byte array up to the next multiple
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random bytes

◆ getbyte() [2/2]

jarray<uint8_t> ProtocolPP::jrand::getbyte ( uint32_t  amount,
bool  use_crypto = false 
)

Method to obtain an array of bytes from the random number generator

Parameters
amount- number of bytes to generate
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random bytes

◆ getchar()

jarray<char> ProtocolPP::jrand::getchar ( uint32_t  amount)

Method to obtain an array of char from the random number generator

Parameters
amount- number of bytes to generate
Returns
Array of random bytes

◆ getdouble() [1/2]

jarray<uint64_t> ProtocolPP::jrand::getdouble ( const char *  range,
bool  use_crypto = false 
)

Method to obtain an array of double words from the random number generator

Parameters
range- String representing a range of sizes ex., "1..256"
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random double words

◆ getdouble() [2/2]

jarray<uint64_t> ProtocolPP::jrand::getdouble ( uint32_t  amount,
bool  use_crypto = false 
)

Method to obtain an array of uint64_t from the random number generator

Parameters
amount- number of uint64_t to generate
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random uint64_t

◆ getname()

std::string ProtocolPP::jrand::getname ( uint32_t  length)

Method to obtain a random name from the random number generator

Parameters
length- length of random string to generate
Returns
randomly generated name

◆ getstr()

std::string ProtocolPP::jrand::getstr ( const char *  input)

Method to obtain a random string from the random number generator

Parameters
input- string of colon separated strings to choose from
Returns
randomly selected string from the input

◆ getu16() [1/2]

jarray<uint16_t> ProtocolPP::jrand::getu16 ( const char *  range,
bool  use_crypto = false 
)

Method to obtain an array of shorts from the random number generator

Parameters
range- String representing a range of sizes ex., "1..256"
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random shorts

◆ getu16() [2/2]

jarray<uint16_t> ProtocolPP::jrand::getu16 ( uint32_t  amount,
bool  use_crypto = false 
)

Method to obtain an array of uint16_t from the random number generator

Parameters
amount- number of uint16_t to generate
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random uint16_t

◆ getword() [1/2]

jarray<uint32_t> ProtocolPP::jrand::getword ( const char *  range,
bool  use_crypto = false 
)

Method to obtain an array of words from the random number generator

Parameters
range- String representing a range of sizes ex., "1..256"
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random words

◆ getword() [2/2]

jarray<uint32_t> ProtocolPP::jrand::getword ( uint32_t  amount,
bool  use_crypto = false 
)

Method to obtain an array of uint32_t from the random number generator

Parameters
amount- number of uint32_t to generate
use_crypto- Uses hardware generated random values, non-reproducible
Returns
Array of random uint32_t

◆ seed() [1/2]

void ProtocolPP::jrand::seed ( std::seed_seq &  myseed)

Method to reseed generator with seed sequence

Parameters
myseed- new seed_seq for random number generator of UINT32

◆ seed() [2/2]

void ProtocolPP::jrand::seed ( uint64_t  myseed)

Method to reseed generator with unsigned long

Parameters
myseed- new seed for random number generator

◆ tokenizer()

static std::vector<std::string> ProtocolPP::jrand::tokenizer ( const char *  input,
const char *  delimiters 
)
static

tokenize the string

Parameters
input- String to tokenize
delimiters- Delimiters to split the string (with no spaces e.g., "-,.|")
Returns
vector containing tokens

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