MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
secret类 参考

真随机数生成器 更多...

#include <random.hpp>

静态 Public 成员函数

static int32_t next_int (int32_t min, int32_t max)
 生成[min, max)范围内的随机整数
static int32_t next_int (const int32_t max)
 生成[0, max)范围内的随机整数
static double next_double ()
 生成[0.0, 1.0)范围内的随机双精度浮点数
static bool is_supported ()
 检查系统是否支持真随机数生成

详细描述

真随机数生成器

使用系统提供的硬件随机源生成真随机数,适用于加密等安全场景。 所有方法都是静态的,不需要实例化。

在文件 random.hpp231 行定义.

成员函数说明

◆ is_supported()

bool secret::is_supported ( )
static

检查系统是否支持真随机数生成

返回
如果系统支持真随机数生成则返回true,否则返回false

◆ next_double()

double secret::next_double ( )
static

生成[0.0, 1.0)范围内的随机双精度浮点数

返回
[0.0, 1.0)范围内的随机双精度浮点数

◆ next_int() [1/2]

int32_t secret::next_int ( const int32_t max)
inlinestatic

生成[0, max)范围内的随机整数

参数
max上限(不包含)
返回
[0, max)范围内的随机整数

在文件 random.hpp246 行定义.

引用了 max() , 以及 next_int().

被这些函数引用 next_int().

◆ next_int() [2/2]

int32_t secret::next_int ( int32_t min,
int32_t max )
static

生成[min, max)范围内的随机整数

参数
min下限(包含)
max上限(不包含)
返回
[min, max)范围内的随机整数

引用了 max() , 以及 min().


该类的文档由以下文件生成: