问题描述:在IDEA和window下,运行AES加密没啥问题,但是打包到linux服务器上进行运行时,出现以下异常:
Exception in thread "main" java.lang.RuntimeException: Illegal key size or default parameters
at com.cupdata.oam.cardapply.kit.AesKit.decrypt(AesKit.java:98)
at com.cupdata.oam.cardapply.kit.AesKit.decrypt(AesKit.java:86)
at com.cupdata.oam.cardapply.kit.AesKit.decryptToStr(AesKit.java:56)
Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026)
at javax.crypto.Cipher.implInit(Cipher.java:801)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1249)
at javax.crypto.Cipher.init(Cipher.java:1186)
原因:环境问题导致的,代码没啥问题
解决办法:
1.下载对应jar包:https://www.oracle.com/technetwork/java/javase/downloads/jce-all-download-5170447.html
2.将jar包解压到【\jre\lib\security】目录下,最好先备份下原有文件 ,如下图所示: