java.security AES 加密密钥长度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19503926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.security AES encryption key length
提问by Cacheing
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.
当密钥长度为 128 位时,一切正常。但是当我使用长度为 192 或 256 位的密钥时,出现以下异常。
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*..)
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 安全性:非法密钥大小或默认参数?. 但是在我下载了 jar 文件并将其放入后${java.home}/lib/security/
,我仍然遇到了同样的异常。
回答by Murph
回答by Cristian Meneses
Java comes with a default maximum strength of 128 bits.
Java 的默认最大强度为 128 位。
What you need is a set of files called Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Filesand 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/securitydirectory of your JRE.
您需要的是一组名为Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 的文件,目前可在Java SE 下载页面 获得。此 zip 文件包含几个策略 jar,您需要将它们复制到JRE的{java.home}/jre/lib/security目录中已有的那些之上。
This will let you change the key strength above 128 bits
这将让您更改 128 位以上的密钥强度