Java implements AES encryption and throws an exception as follows:
Java.security.InvalidKeyException:Illegal Key Size
Code reference HTTP://MY.OSCHINA.NET/JACKER/BLOG/86383?FROMERR=X3L5XL1A
Reason:
Illegal key size or default parameters means that the key length is limited,
The Java Runtime environment reads a restricted policy file.
The policy file is located in the ${java_home}/jre/lib/security directory.
This limitation is due to U.S. control over software exports.
Workaround:
To remove this restriction, simply download the Java Cryptography Extension (JCE) Unlimited strength Jurisdiction Policy Files,
Overwrite the corresponding jar file (Local_policy.jar, Us_export_policy.jar) in the above directory.
:
JDK6 http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
JDK7 http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
JDK8 http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
The Readme.txt of the download package has the installation instructions, which is replaced
${jdk_home}/jre/lib/security
${jre_home}/lib/security
The Local_policy.jar and Us_export_policy.jar files in the directory.
Reference Http://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters
Java implementation AES encryption, exception Java.security.InvalidKeyException:Illegal key size resolution