我想在Windows上利用英特尔的RDRAND功能并生成真实的随机数(因为Python的随机模块不是那么随机)。 Python中是否有任何API可以访问此功能?

我尝试安装下面的注释中提到的rdrand模块,但始终收到错误消息。日志:http://pastebin.com/A2Vqsqec

rdrand.c中的这些行似乎抛出了错误:

#ifdef __GNUC__
#define USING_GCC 1
#elif __clang__
#define USING_CLANG 1
#else
#error Only support for gcc or clang currently
#error if you port to another compiler, please
#error send back the patch to https://github.com/stillson/rdrand
#endif


为什么会这样呢?

更新:我已经检查并确保已定义__GNUC__

最佳答案

您可能想使用Python来包装C / C ++例程,而不是使用RdRand()的Python实现。此处的研究论文(http://iopscience.iop.org/article/10.3847/1538-4357/aa7ede/meta;jsessionid=A9DA9DDB925E6522D058F3CEEC7D0B21.ip-10-40-2-120)或此处的非付费版本(https://arxiv.org/abs/1707.02212)最近显示了Python中RdRand()的性能有多差。即使如此,正如论文所提到的,RdRand和RdSeed指令并不是完全“真正”随机的。

希望能有所帮助。

08-19 21:46