mysql aes密钥大于16位_Java AES密钥长度超过16报错的问题

本文介绍了在Java中使用AES加密时遇到密钥长度超过16位导致的错误,问题根源在于Java的JCE政策文件限制。提供了解决方案,包括下载并替换JCE解封jar包,修改java.security文件,以及针对不同Java版本的处理方法。通过实际操作展示了如何在不同Java版本下执行24位密钥长度的AES加密。
摘要由CSDN通过智能技术生成

一、发现现象

在用Java编写一个项目时,使用了AES作为数据库某些字段的加密方式,在Windows上正常运行,在Linux上调用AWS加密,抛出异常:No installed provider supports this key: javax.crypto.spec.SecretKeySpec

二、问题根源

Java的政策文件限制了密钥长度。

JCE(Java Cryptography Extension)是Java的加密扩展包,由于美国对某些国家有进出口限制,因此低版本Java默认限制了密钥长度,比如AES加密只能使用16位AES-128,超过16位就会报这个错。Unlimited Strength Java Cryptography Extension

Due to import control restrictions for some countries, the Java Cryptography Extension (JCE) policy files shipped with the JDK and the JRE allow strong but limited cryptography to be used. These files are located at: /lib/security/local_policy.jar /lib/security/US_export_policy.jar where is the jre directory of the JDK or the top-level directory of the JRE.

An unlimited strength version of these files indicating no restrictions on cryptographic strengths is available on the JDK web site for those living in el

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值