java.security.NoSuchAlgorithmException: Cannot find any provider supporting DESede/CBC/PKCS5Padding

最近在做3DES加密,在本地window下面运行ok的程序,放到linux环境上竟然报错:

at javax.crypto.Cipher.getInstance(Cipher.java:524)

at com.haha.encrypt.ThreeDES.encryptMode(ThreeDES.java:30)

at com.haha.encrypt.ThreeDES.encryptString(ThreeDES.java:101)

at com.haha.mina.MinaServerHandler.sessionIdle(MinaServerHandler.java:91)

at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionIdle(DefaultIoFilterChain.java:665)

at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionIdle(DefaultIoFilterChain.java:398)

at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1000(DefaultIoFilterChain.java:47)

at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionIdle(DefaultIoFilterChain.java:755)

at org.apache.mina.core.filterchain.IoFilterAdapter.sessionIdle(IoFilterAdapter.java:95)

at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionIdle(DefaultIoFilterChain.java:398)

at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1000(DefaultIoFilterChain.java:47)

at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionIdle(DefaultIoFilterChain.java:755)

at org.apache.mina.core.filterchain.IoFilterAdapter.sessionIdle(IoFilterAdapter.java:95)

at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionIdle(DefaultIoFilterChain.java:398)

at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionIdle(DefaultIoFilterChain.java:391)

at org.apache.mina.core.session.AbstractIoSession.notifyIdleSession0(AbstractIoSession.java:1303)

at org.apache.mina.core.session.AbstractIoSession.notifyIdleSession(AbstractIoSession.java:1289)

at org.apache.mina.core.session.AbstractIoSession.notifyIdleness(AbstractIoSession.java:1274)

at org.apache.mina.core.polling.AbstractPollingIoProcessor.notifyIdleSessions(AbstractPollingIoProcessor.java:760)

at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$900(AbstractPollingIoProcessor.java:67)

at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1135)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:744)

对比了下Security.getProviders()

window下:

INFO  2014-04-30 10:32:12   ServerStarter:67 - 0[SUN]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 1[SunRsaSign]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 2[SunEC]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 3[SunJSSE]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 4[SunJCE]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 5[SunJGSS]

INFO  2014-04-30 10:32:12  ServerStarter:67 - 6[SunSASL]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 7[XMLDSig]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 8[SunPCSC]

INFO  2014-04-30 10:32:12   ServerStarter:67 - 9[SunMSCAPI]

linux下:

INFO  2014-04-30 10:33:55   ServerStarter:66 - 0[SUN]

INFO  2014-04-30 10:33:55   ServerStarter:66 - 1[SunRsaSign]

INFO  2014-04-30 10:33:55   ServerStarter:66 - 2[SunJSSE]

INFO  2014-04-30 10:33:55   ServerStarter:66 - 3[SunJGSS]

INFO  2014-04-30 10:33:55   ServerStarter:66 - 4[SunSASL]

INFO  2014-04-30 10:33:55   ServerStarter:66 - 5[XMLDSig]

INFO  2014-04-30 10:33:56   ServerStarter:66 - 6[SunPCSC]

怀疑是缺少SunJCE造成的,但是在linux的JAVA_HOME/jre/lib/ext目录下,有sunjce_provider.jar包,所以很奇怪。

百思不得其姐,最后在一篇文章里,找到一句话,“找到一个 sunjce_provider.jar 的文件扔到你类路径里”,结果,ok了。。。。

java.security.NoSuchAlgorithmException: Cannot find any provider supporting DESede/CBC/PKCS5Padding,码迷,mamicode.com

时间: 2024-10-12 16:12:16

java.security.NoSuchAlgorithmException: Cannot find any provider supporting DESede/CBC/PKCS5Padding的相关文章

java PKCS7Padding 加密Cannot find any provider supporting AES/CBC/PKCS7Padding 解决办法

在java中用aes256进行加密,但是发现java里面不能使用PKCS7Padding,而java中自带的是PKCS5Padding填充,那解决办法是,通过BouncyCastle组件来让java里面支持PKCS7Padding填充. 説辣么多不如上代码: public class AESUtil { /** * Encodes a String in AES-256 with a given key * * @param context * @param password * @param

java.security.NoSuchAlgorithmException: AES KeyGenerator not available

异常信息 Caused by: Java.lang.IllegalStateException: Unable to acquire AES algorithm. This is required to function. at org.apache.shiro.crypto.AbstractSymmetricCipherService.generateNewKey(AbstractSymmetricCipherService.java:59) at org.apache.shiro.crypt

java.security.NoSuchAlgorithmException: SHA1PRNG SecureRandom not available

q好久没有使用MyEclipse10了,今天打开看了以前大学的项目,在Tomcat7中发布启动,我嚓嘞,报错: SEVERE: Exception initializing random number generator using algorithm [SHA1PRNG] java.security.NoSuchAlgorithmException: SHA1PRNG SecureRandom not available at sun.security.jca.GetInstance.getI

Java Security:Java加密框架(JCA)简要说明

加密服务总是关联到一个特定的算法或类型,它既提供了密码操作(如Digital Signature或MessageDigest),生成或供应所需的加密材料(Key或Parameters)加密操作,也会以一个安全的方式生成数据对象(KeyStore或Certificate),封装(压缩)密钥(可以用于加密操作). Java Security API中,一个engine class就是定义了一种加密服务,不同的engine class提供不同的服务.下面就来看看有哪些engine class: 1)M

Java security MD5加密算法

利用java.security对字符串进行MD5加密: 1 import java.security.MessageDigest; 2 import java.security.NoSuchAlgorithmException; 3 4 public class MD5 { 5 public static final String MD5CODE = ""; 6 7 private static MessageDigest messageDigest = null; 8 9 publi

利用Java自带的MD5加密java.security.MessageDigest;

MD5加密算法,即"Message-Digest Algorithm 5(信息-摘要算法)",它由MD2.MD3.MD4发展而来的一种单向函数算法(也就是HASH算法),它是国际著名的公钥加密算法标准RSA的第一设计者R.Rivest于上个世纪90年代初开发出来的.MD5的最大作用在于,将不同格式的大容量文件信息在用数字签名软件来签署私人密钥前"压缩"成一种保密的格式,关键之处在于——这种"压缩"是不可逆的. Java JDK已经自带了MD5的实

java.security 生成MD5

package com.tylor.util; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * @author tylor * 2017年8月23日 */ public class Md5Util { public static String getMD5(String str) { try { // 生成一个

andorid HTTPS 不需要证书 VolleyEror: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not fou

1.加证书(这里不说) 2.修改代码 import java.security.KeyManagementException;import java.security.NoSuchAlgorithmException;import java.security.SecureRandom;import java.security.cert.X509Certificate;import javax.net.ssl.HostnameVerifier;import javax.net.ssl.HttpsU

Java加密工具类(依赖:java.security.MessageDigest或org.apache.commons.codec.digest.DigestUtils)

依赖于java.security.MessageDigest,支持MD5,SHA-1,SHA-256 1 import java.security.MessageDigest; 2 import java.security.NoSuchAlgorithmException; 3 4 /** 5 * CiphertextUtil 6 * 7 * @author ysj 8 */ 9 public class CiphertextUtil { 10 public static final Strin