如何使用python程序手动生成熵?

2024-10-01 02:21:19 发布

您现在位置:Python中文网/ 问答频道 /正文

最常见的随机性来源是Windows系统中的CrypAPI。如果不在python中使用这个API,我可以从不同的源生成自己的熵吗?有这样的图书馆吗?我想修改一下生成过程并了解一下RNG。在


Tags: api图书馆过程windows系统来源rng随机性
1条回答
网友
1楼 · 发布于 2024-10-01 02:21:19

当然,你可以从提供随机噪音的网站上得到

https://www.random.org/strings/

随机性来自大气噪声,在许多方面比计算机程序中常用的伪随机数算法好

使用BeautifulSoup来删除页面

import urllib2
from bs4 import BeautifulSoup

# specify the url
rng_page = ‘https://www.random.org/strings/'

# query the website and return the html to the variable ‘page’
page = urllib2.urlopen(rng_page)

# parse the html using beautiful soup and store in variable `soup`
soup = BeautifulSoup(page, ‘html.parser’)

....

相关问题 更多 >