gpt4 book ai didi

php - php的random_int()函数分布

转载 作者:搜寻专家 更新时间:2023-10-31 21:53:19 25 4
gpt4 key购买 nike

php的random_int的分布是什么?功能?

我猜这归结为 getrandom(2) 的分布和/dev/urandom?它们是如何分布的?

random_int 可以用于均匀分布的随机数生成器吗?

最佳答案

来自 random_int 的 php 手册:

On Windows, CryptGenRandom() will always be used.
On Linux, the getrandom(2) syscall will be used if available.
On other platforms, /dev/urandom will be used.

这意味着分发依赖于操作系统...
所以,我认为回答最初的问题“php 的 random_int 函数的分布是什么?”并不是那么容易。在 Linux 上,例如,来自 a discussion关于 int getrandom(void *buf, size_t buflen, unsigned int flags);:

[...] The GRND_RANDOM flag bit can be used to switch to the /dev/random pool, subject to the entropy requirements of that pool [...]

因此,基于不同的运行时参数,随机分布在相同操作系统中可能会有所不同...

关于php - php的random_int()函数分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36874578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com