gpt4 book ai didi

javascript - Meteor-Random - 如何知道生成器是强还是弱

转载 作者:行者123 更新时间:2023-12-02 15:29:45 25 4
gpt4 key购买 nike

meteor 文档位于 http://docs.meteor.com/#/full/random说:

... It uses a cryptographically strong pseudorandom number generator when possible, but falls back to a weaker random number generator when cryptographically strong randomness is not available (on older browsers or on servers that don't have enough entropy to seed the cryptographically strong generator).

问:我可以在脚本中的某个位置获取是否可以生成强随机生成器的信息。

我想显示一个像这样的框:“抱歉,您无法在您的环境中生成强随机数”,而不是创建较弱的随机数。

感谢您的一些反馈汤姆

最佳答案

看代码: https://github.com/meteor/meteor/blob/devel/packages/random/random.js

我看到 Random 对象的“type”属性,它指示正在使用哪种类型的随机数生成器。

提取的值:

  • NODE_CRYPTO - 使用 Node.js RNG - 大概不会在浏览器中
  • BROWSER_CRYPTO - 使用网络浏览器的随机数生成器 - 假定为字符串
  • ALEA - JavaScript 中的“不安全”随机数生成器实现

因此,您可以通过查询这些字符串之一的“Random.type”值来检查正在使用的随机数生成器。

关于javascript - Meteor-Random - 如何知道生成器是强还是弱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33421162/

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