AES加密java.security.InvalidKeyException: Illegal key size or default parameters

java.security.InvalidKeyException: Illegal key size or default parameters**

使用AES加密时,当密钥大于128字节时,代码会抛出java.security.InvalidKeyException: Illegal key size or default parameters

Illegal key size or default parameters是指密钥长度是受限制的,java运行时环境读到的是受限的policy文件。文件位于${java_home}/jre/lib/security

点击下载相应文件:

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6 Download

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 Download

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 Download

replace the file in ${java.home}/jre/lib/security/

你可能感兴趣的:(java)