在進行 Java AES 加密測試時,出現以下錯誤信息:html
java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026) at javax.crypto.Cipher.implInit(Cipher.java:801) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1249) at javax.crypto.Cipher.init(Cipher.java:1186)
由於超出了JDK 默認的祕鑰長度,若需放開,則須要更新 JDK 中相應的 jar 文件(local_policy.jar 、US_export_policy.jar),相應的下載連接以下所示:java
http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.htmloracle
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.htmlide
http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html測試
請依據相應安裝的 JDK 版本進行下載,下載後解壓到 JDK 安裝目錄下的 jre/lib/security 文件夾下,重啓應用便可。加密