我有这段代码:
class Crypt
{
Key KEY;
String TD;
Cipher aes = Cipher.getInstance("AES/CBC/PKCS5Padding");
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
public Crypt()
{
int keyLength = 192;
keyGen.init(keyLength);
KEY = keyGen.generateKey();
当编译时出现此错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Unhandled exception type NoSuchAlgorithmException
Unhandled exception type NoSuchPaddingException
Unhandled exception type NoSuchAlgorithmException
答案 0 :(得分:2)
您的错误非常明确,与无限制的管辖区加密文件无关。它告诉你有未处理的检查异常。
将throws Exception
添加到构造函数中,使其如下所示:
public Crypt() throws Exception
{
int keyLength = 192;
keyGen.init(keyLength);
KEY = keyGen.generateKey();
答案 1 :(得分:1)
您是否也将它们安装到/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/security?