小毛的胡思乱想

凡走过,必留痕迹.

AES256算法遇到 Illegal Key Size or Default Parameters的解决办法

| Comments

1
2
3
4
5
6
7
8
java.security.InvalidKeyException: Illegal key size or default parameters
  at javax.crypto.Cipher.a(DashoA13*..)
  at javax.crypto.Cipher.a(DashoA13*..)
  at javax.crypto.Cipher.a(DashoA13*..)
  at javax.crypto.Cipher.init(DashoA13*..)
  at javax.crypto.Cipher.init(DashoA13*..)
  at com.xxx.AESWithFileKey.encrypt(AESWithFileKey.java:81)
  at com.xxx.AESWithFileKey.main(AESWithFileKey.java:148)

Google到问题原因,链接地址如下:http://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters

根据回答找到下载新jar包链接地址如下:http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
把里面的两个jar包:local_policy.jar 和 US_export_policy.jar 替换掉原来安装目录C:\Program Files\Java\jre6\lib\security 下的两个jar包就可以了

上面是在oracle的jdk出现的。 如果是IBM的jdk出现问题,参考调整 Version 7.0 应用程序的 Web Services Security

Comments