我正在学习 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 模块的 >documentation 是这样说的:
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生成真实的随机数吗?
发布评论