Related to random number and string generation.
More...
#include <sttnet_English.h>
|
| static long | getRandomNumber (const long &a, const long &b) |
| | Generate a random integer. More...
|
| |
| static std::string & | getRandomStr_base64 (std::string &str, const int &length) |
| | Generate a pseudo-random string of specified length within the Base64 character set, and append '=' at the end to complete the Base64 string format. More...
|
| |
| static std::string & | generateMask_4 (std::string &mask) |
| | Generate a 32-bit (4-byte) random mask. More...
|
| |
Related to random number and string generation.
| static std::string& stt::data::RandomUtil::generateMask_4 |
( |
std::string & |
mask | ) |
|
|
static |
Generate a 32-bit (4-byte) random mask.
This function first randomly generates a 32-bit string composed of '0' and '1' (e.g., "010110..."), then converts it into the corresponding 4-byte binary data through the internal BitUtil::toBit() function.
The conversion result is returned via the mask parameter, which is typically used to generate packet masks, encryption masks, bitmap masks, etc.
- Parameters
-
| mask | Used to store the final generated 4-byte mask (binary string form). |
- Returns
- Reference to mask.
- Note
- Internally depends on the function
BitUtil::toBit(const std::string&, std::string&) to compress the 32-bit binary string into 4 bytes.
| static long stt::data::RandomUtil::getRandomNumber |
( |
const long & |
a, |
|
|
const long & |
b |
|
) |
| |
|
static |
Generate a random integer.
- Parameters
-
| a | Lower bound of the random number range |
| b | Upper bound of the random number range |
- Note
- Generate a random number in the range [a, b]
- Returns
- The generated random number
| static std::string& stt::data::RandomUtil::getRandomStr_base64 |
( |
std::string & |
str, |
|
|
const int & |
length |
|
) |
| |
|
static |
Generate a pseudo-random string of specified length within the Base64 character set, and append '=' at the end to complete the Base64 string format.
- Parameters
-
| str | Container to save the generated string |
| length | Length of the string to generate |
- Returns
- Reference to str
The documentation for this class was generated from the following file: