我有这个小程序在我的JDK安装中打印出所有支持的提供程序,但我想知道是否有人知道如何更改此程序以打印出每个提供程序的“强度”?
import java.security.Provider;
import java.security.Security;
public class SecurityListings
{
public static void main(String[] args)
{
for (Provider provider : Security.getProviders())
{
System.out.println("Provider: " + provider.getName());
for (Provider.Service service : provider.getServices())
{
System.out.println(" Algorithm: " + service.getAlgorithm());
}
}
}
}
解决方法
Cipher.getMaxAllowedKeyLength()
传递转换,它将返回允许的最高键.
这是一个简单的检查
public bool isUnlimitedKeyStrength() {
return Cipher.getMaxAllowedKeyLength("AES") == Integer.MAX_VALUE;
}