我正在尝试在 /dev/random
的机器上运行代码不会很快填满,我正在尝试使用的 Java 程序因缺少随机数而挂起。/dev/urandom
产生“不太好”的随机数,但不会阻塞,对于这种情况,我宁愿有更少的随机性和完成性,而不是更好的随机性但永远不会完成。
我尝试将其传递给 java
-Djava.security.egd=file:/dev/./urandom
但它没有解决任何问题(“/dev/urandom”在某些地方有问题,而“/dev/./urandom”在任何地方都有效,这就是我使用该路径的原因)。有没有办法做到这一点?我现在试过:
file:/dev/./urandom
file://dev/./urandom
file:///dev/./urandom
file:/dev/urandom
file://dev/urandom
file:///dev/urandom
没有人工作过
最佳答案
fileurl
确实需要 2-3 个正斜杠(根据 RFC 1738 ):
-Djava.security.egd=file://dev/./urandom
-Djava.security.egd=file://dev/urandom
NativePRNG
,但不是 SHA1PRNG
算法。解释如下:What java.security.egd option is for?查看可用内容:cat /dev/./urandom
和 cat /dev/urandom
. manpages状态,人们可以简单地创 build 备,以防它们不存在。The
/dev/random
device is a scarce shared system resource that Linux Container tenants likely have not realised they are sharing. When they all try to use it at the same time they are effectively causing a denial of service on each other.
关于java - 如何更改随机数据的 Java 源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68910456/