gpt4 book ai didi

java - SecureRandom 的 SHA1PRNG 算法是否使用/dev/random 作为熵?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:57:53 24 4
gpt4 key购买 nike

我试着在 javadocs 和网上寻找这个,但找不到明确的答案。 Dan Dyer 在

中的回答

How to solve performance problem with Java SecureRandom?

似乎表明 SHA1PRNG 不使用任何系统资源来获取熵。这是正确的吗?

最佳答案

不,在默认的 Oracle 实现中,它使用系统资源,除非您在调用 nextBytes() 之前为它播种。来自 SecureRandom 的 Sun/Oracle 文档:

The SecureRandom implementation attempts to completely randomize the internal state of the generator itself unless the caller follows the call to a getInstance method with a call to the setSeed method:

 SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
random.setSeed(seed);

关于java - SecureRandom 的 SHA1PRNG 算法是否使用/dev/random 作为熵?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13923247/

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