我正在学习python的随机模块.而且我知道它会生成伪随机数.它的核心思想是使用高频时钟作为种子,然后使用一个函数产生一个看起来像随机数".
I'm learning random module of python. And I know it generates pseudo random number. Which its core idea is to use a high-frequency clock as a seed and then use a function to produce a 'looking-like random number.
据我所知,在现实世界中甚至不可能生成真实的随机数.
As I know it's even impossible to produce authentic random number in the real world.
但是我知道Unix随机产生器引入了其他一些因素,例如鼠标移动轨迹的参数,IO响应时间,以为其随机数产生器函数引入不确定性.通过该方法,我们可以获得比普通伪随机数更好的随机数.很难预测.
But I know Unix random producer has introduced some other factors such as the parameter of mouse-movement track, the IO response time, to introduce uncertainty to its random number producer function. Through which we can get a better random number than normal pseudo random number. It's much more harder to predict.
那么,有没有一种方法可以在python中生成这样一个随机数,或者可以导入一个好的第三方库?
So, is there a way that in python we can produce such a random number, or maybe import a good third party library?
推荐答案random模块的>文档这样说:
The documentation for the random module has this to say:
警告:不应出于安全目的使用此模块的伪随机数生成器.如果需要加密安全的伪随机数生成器,请使用os.urandom()或SystemRandom.
Warning: The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.
更多推荐
我可以使用python生成真实的随机数吗?
发布评论