Java implements AES encryption and throws an exception as follows:
java.security.InvalidKeyException: Illegal key size
Code referencehttp: //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 the restricted policy file.
The policy file is located in the ${java_home}/jre/lib/security directory.
This restriction is because of US controls on software exports.
Solution:
To remove this restriction, just download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files,
Just overwrite the corresponding jar files (local_policy.jar, US_export_policy.jar) in the above directory.
Download address:
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 installation instructions, that is, replace
${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