Java implementation AES encryption, exception Java.security.InvalidKeyException:Illegal key size resolution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.