我知道使用 RNGCryptoServiceProvider
,但是我需要做什么特殊的事情来确保它不会每次都使用相同的种子(例如在启动时)?我需要在初始化时从外部来源提取一些数据吗?或者系统会为我做这件事吗?
最佳答案
很棒的 Microsoft 文档,找不到有关算法或种子的任何内容。
Windows developers have several alternative means of accessing the CryptGenRandom functionality; these alternatives invoke the same algorithm and share the same security characteristics, but may have other advantages.
...
Using RNGCryptoServiceProvider
Programmers using .NET should use the RNGCryptoServiceProvider Class
请注意,维基百科似乎已经过时,有关更多最新信息,请查看 the Microsoft pages of the CryptGenRandom function
<小时/>请注意,只有当您实际获得使用 CryptGenRandom
函数的 Microsoft CSP 时,此答案才有效。如果您使用的是非 Windows 平台,或者您引用的是不同的 CSP,请检查这些特定的运行时配置。
关于c# - 如何在 Azure 辅助角色中生成安全随机数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23620465/