我可以使用python生成真实的随机数吗? [英] Can I generate authentic random number with python?

查看:713
本文介绍了我可以使用python生成真实的随机数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习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生成真实的随机数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆