方法SecureRandom.getInstanceStrong()
声明它可以抛出 NoSuchAlgorithmException
,但是文档说:
Every implementation of the Java platform is required to support at least one strong SecureRandom implementation.
什么情况下会抛出这个异常?仅当属性 securerandom.strongAlgorithms
是用户定义且未列出算法时才会发生这种情况吗?
最佳答案
如果 securerandom.strongAlgorithms
配置不正确,似乎确实会引发此异常。未经检查的异常可能是更好的选择。
if (property == null || property.isEmpty()) {
throw new NoSuchAlgorithmException(
"Null/empty securerandom.strongAlgorithms Security Property");
}
...
throw new NoSuchAlgorithmException(
"No strong SecureRandom impls available: " + property);
关于java - SecureRandom.getInstanceStrong() 何时抛出 NoSuchAlgorithmException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55675003/