java.security AES加密密钥长度 [英] java.security AES encryption key length
问题描述
当密钥长度为128位时,一切正常。但是,当我使用长度为192或256位的密钥时,出现以下异常。
When the key length is 128 bits,everything works. But I got the following exception when I use a key of length 192 or 256 bits.
java.security.InvalidKeyException: Illegal key size or default parameters
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
我发现了这个 Java安全性:密钥大小或默认参数非法?。但是,在下载jar文件并将其放在 $ {java.home} / lib / security /
之后,我仍然遇到相同的异常。
I found this Java Security: Illegal key size or default parameters?. But after I download the jar files and put it in ${java.home}/lib/security/
, I still got the same exception.
推荐答案
Java的默认最大强度为128位。
Java comes with a default maximum strength of 128 bits.
您需要的是一组称为 Java密码学扩展(JCE)无限强度管辖权策略文件的文件,目前可在 Java SE下载页面。该zip文件包含几个策略jar,您需要将其复制到JRE的 {java.home} / jre / lib / security 目录中已有的策略jar中。
What you need is a set of files called Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files and is currently available at the Java SE download page. This zip file contains a couple of policy jars, which you need copy over the top of the ones already in the {java.home}/jre/lib/security directory of your JRE.
这将使您将密钥强度更改为128位以上
This will let you change the key strength above 128 bits
这篇关于java.security AES加密密钥长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!