AES encryption throws java.security.InvalidKeyException: Illegal key size or default parameter

When using AES encryption, when the key is greater than 128, the code will throw java.security.InvalidKeyException: Illegal key size or default parameters

Illegal key size or default parameters means that the key length is limited, and the java runtime environment reads the limited policy file. The file is located in ${java_home}/jre/lib/security

This restriction is because of US controls on software exports.

 

Solution:

Removing this restriction requires downloading the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. The URL is as follows.

The readme.txt of the download package has installation instructions. Just replace local_policy.jar and US_export_policy.jar under ${java_home}/jre/lib/security/

jdk 5: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-plat-419418.html#jce_policy-1.5.0-oth-JPR

jdk6: http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html


Reference http://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters

 

Rotor:

  http://blog.csdn.net/shangpusp/article/details/7416603

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326269063&siteId=291194637