3.上传好了之后启动tomcat服务器,java中的 DES 加密与解密

那么系统会默认启动OpenJDK,3.上传好了之后启动tomcat服务器,testCipher(nuim.cs.crypto.ibe.test.IbeProviderTest) Time elapsed,sec &lt,at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java,sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java,import,java import,java中的 DES 加密与解密

图片 2

图片 1

testCreateCipher(nuim.cs.crypto.ibe.test.IbeProviderTest) Time elapsed:
0 sec <<< ERROR!
java.lang.SecurityException: JCE cannot authenticate the provider
NUIMCSCGIBE
at javax.crypto.Cipher.getInstance(Cipher.java:642)
at
nuim.cs.crypto.ibe.test.IbeProviderTest.testCreateCipher(IbeProviderTest.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.SecurityException: Cannot verify
jar:file:/F:/Workspace/GitHub/IBE/framework/target/classes/!/
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:406)
at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:322)
at javax.crypto.JarVerifier.verify(JarVerifier.java:250)
at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:161)
at
javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:187)
at javax.crypto.Cipher.getInstance(Cipher.java:638)
… 26 more
Caused by: java.security.PrivilegedActionException:
java.io.FileNotFoundException:
F:\Workspace\GitHub\IBE\framework\target\classes
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:384)
… 31 more
Caused by: java.io.FileNotFoundException:
F:\Workspace\GitHub\IBE\framework\target\classes
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:215)
at java.util.zip.ZipFile.(ZipFile.java:145)
at java.util.jar.JarFile.(JarFile.java:154)
at java.util.jar.JarFile.(JarFile.java:91)
at sun.net.www.protocol.jar.URLJarFile.(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at
sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:109)
at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at
sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
at javax.crypto.JarVerifier$2.run(JarVerifier.java:399)
… 33 more

tomcat7 PermGen space 天天叁次 50C
Exception in thread “http-bio-443-exec-1832” at
sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at
sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:94)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:48)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.security.Provider$Service.newInstance(Provider.java:1240)
at javax.crypto.Cipher.chooseProvider(Cipher.java:845)
at javax.crypto.Cipher.init(Cipher.java:1348)
at sun.security.ssl.CipherBox.(CipherBox.java:175)
at sun.security.ssl.CipherBox.newCipherBox(CipherBox.java:208)
at
sun.security.ssl.CipherSuite$BulkCipher.newCipher(CipherSuite.java:471)
at sun.security.ssl.Handshaker.newReadCipher(Handshaker.java:707)
at
sun.security.ssl.SSLSocketImpl.changeReadCiphers(SSLSocketImpl.java:2063)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1117)
at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.getSession(SSLSocketImpl.java:2191)
at
org.apache.tomcat.util.net.jsse.JSSESocketFactory.handshake(JSSESocketFactory.java:252)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
java.lang.OutOfMemoryError: PermGen space
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at
sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:94)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:48)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.security.Provider$Service.newInstance(Provider.java:1240)
at javax.crypto.Cipher.chooseProvider(Cipher.java:845)
at javax.crypto.Cipher.init(Cipher.java:1348)
at sun.security.ssl.CipherBox.(CipherBox.java:175)
at sun.security.ssl.CipherBox.newCipherBox(CipherBox.java:208)
at
sun.security.ssl.CipherSuite$BulkCipher.newCipher(CipherSuite.java:471)
at sun.security.ssl.Handshaker.newReadCipher(Handshaker.java:707)
at
sun.security.ssl.SSLSocketImpl.changeReadCiphers(SSLSocketImpl.java:2063)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1117)
at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.getSession(SSLSocketImpl.java:2191)
at
org.apache.tomcat.util.net.jsse.JSSESocketFactory.handshake(JSSESocketFactory.java:252)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
java.lang.OutOfMemoryError: PermGen space
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at
sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:94)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:48)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.security.Provider$Service.newInstance(Provider.java:1240)
at javax.crypto.Cipher.chooseProvider(Cipher.java:845)
at javax.crypto.Cipher.init(Cipher.java:1348)
at sun.security.ssl.CipherBox.(CipherBox.java:175)
at sun.security.ssl.CipherBox.newCipherBox(CipherBox.java:208)
at
sun.security.ssl.CipherSuite$BulkCipher.newCipher(CipherSuite.java:471)
at sun.security.ssl.Handshaker.newReadCipher(Handshaker.java:707)
at
sun.security.ssl.SSLSocketImpl.changeReadCiphers(SSLSocketImpl.java:2063)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1117)
at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.getSession(SSLSocketImpl.java:2191)
at
org.apache.tomcat.util.net.jsse.JSSESocketFactory.handshake(JSSESocketFactory.java:252)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
java.lang.OutOfMemoryError: PermGen space
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
at
sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
at
sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:94)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:48)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.security.Provider$Service.newInstance(Provider.java:1240)
at javax.crypto.Cipher.chooseProvider(Cipher.java:845)
at javax.crypto.Cipher.init(Cipher.java:1348)
at sun.security.ssl.CipherBox.(CipherBox.java:175)
at sun.security.ssl.CipherBox.newCipherBox(CipherBox.java:208)
at
sun.security.ssl.CipherSuite$BulkCipher.newCipher(CipherSuite.java:471)
at sun.security.ssl.Handshaker.newReadCipher(Handshaker.java:707)
at
sun.security.ssl.SSLSocketImpl.changeReadCiphers(SSLSocketImpl.java:2063)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1117)
at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.getSession(SSLSocketImpl.java:2191)
at
org.apache.tomcat.util.net.jsse.JSSESocketFactory.handshake(JSSESocketFactory.java:252)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Exception in thread “http-bio-443-exec-2025” java.lang.OutOfMemoryError:
PermGen space

} “`

java中的 DES 加密与解密

万大器晚成现身不能访谈,请检查端口8080是还是不是被防火墙拦截 ping ip 端口号 

  • This class provides a key pair generator and an El-Gamal based
    cipher for
  • Identity Based Encryption .
    /
    public class IbeProvider extends Provider {
    /
    * the name of the cipher and key pair generators for ibe /
    public static final String IBE = new String;
    /
    *

    • */private static final long serialVersionUID = 1L;

    /**

    • Creates a new instance of the Crypto Group’s provider for IBE.
      */
      public IbeProvider() {
      super(“NUIMCSCGIBE”, 1.0, “NUIM CS CG IBE Crypto Provider”);

      // clears the superclass provider – don’t want any surprises
      clear();
      // add in our own implementations
      put(“KeyPairGenerator.” + IBE,
      IbeKeyPairGenerator.class.getName;
      put(“Cipher.” + IBE, IbeCipher.class.getName;
      }
      }

import javax.crypto.BadPaddingException; import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException; import
javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;

DES类

package dao;
import java.security.Security;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class DES {

public static String ALGORITHM_DES="DES"; //加密算法的名称 public static KeyGenerator keygen; //密钥生成器 public static SecretKey secretKey; //密钥 public static Cipher cipher; //密码器public byte[] bytes;static{ Security.addProvider(new com.sun.crypto.provider.SunJCE; try{ keygen=KeyGenerator.getInstance(ALGORITHM_DES); secretKey=keygen.generateKey(); cipher=Cipher.getInstance(ALGORITHM_DES); }catch(Exception e){ e.printStackTrace(); }}//加密public byte[] encryptor(String str){ try { cipher.init(Cipher.ENCRYPT_MODE, secretKey); //初始化密码器,用密钥 secretKey 进入加密模式 bytes=cipher.doFinal(str.getBytes; //加密 } catch (Exception e) { e.printStackTrace(); } return bytes;}//解密public String decryptor(byte[] buff){ try { cipher.init(Cipher.DECRYPT_MODE, secretKey); //初始化密码器,用密钥 secretKey 进入解密模式 bytes=cipher.doFinal; } catch (Exception e) { e.printStackTrace(); } return (new String;}

}

javax.crypto.BadPaddingException: Invalid pad value!
at sun.security.pkcs11.P11Cipher$PKCS5Padding.unpad(P11Cipher.java:106)[sunpkcs11.jar:1.7.0_45]
at sun.security.pkcs11.P11Cipher.implDoFinal(P11Cipher.java:802)[sunpkcs11.jar:1.7.0_45]
at sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:542)[sunpkcs11.jar:1.7.0_45]
at sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:525)[sunpkcs11.jar:1.7.0_45]
at javax.crypto.Cipher.doFinal(Cipher.java:1922)[:1.7.0_45]
at com.idcq.appserver.utils.AESUtil.aesDecryptByBytes(AESUtil.java:193)[AESUtil.class:]
at com.idcq.appserver.utils.AESUtil.aesDecrypt(AESUtil.java:211)[AESUtil.class:]

JCE cannot authenticate the provider NUIMCSCGIBE
IbeProvider.class
package nuim.cs.crypto.ibe;

<无详细内容>“` java import
java.io.UnsupportedEncodingException; import
java.security.InvalidKeyException; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import
java.security.PrivateKey; import java.security.PublicKey; import
java.security.SecureRandom;

index.jsp

图片 2

%>

本人的主题材料:在 index.jsp 页面里提交的超链接 德姆o 提交到 Action
,然则某个击,后台就报错:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of
8 when decrypting with padded cipher
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:750)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.DESCipher.engineDoFinal(DESCipher.java:314)
at javax.crypto.Cipher.doFinal(Cipher.java:2087)
at dao.DES.decryptor(DES.java:44)
at filter.MyFilter.doFilter(MyFilter.java:36)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at java.lang.String.(Unknown Source)
at dao.DES.decryptor(DES.java:48)
at filter.MyFilter.doFilter(MyFilter.java:36)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
解密前:product_id=[B@3242ef

是哪儿写的非平常,请大师指引,作者的目标是从 index.jsp
把值(product_id卡塔尔进行加密,在 Action 里面取出加密后的字符串,实行解密,但解密那一块有题目,只怕是 DES
类写的有标题,请权威扶持在原来的代码底工上改造。成分谢谢!!