2017-02-18 24 views
0

내 암호 화기 클래스 메서드 이유 : 나는 다음과 같은 암호화하기 위해 노력하고여기 org.jasypt.exceptions.EncryptionOperationNotPossibleException

public String encrypt(String str){ 
     if(str == null || str.equals("")){ 
      str = ""; 
     } 
     else{ 
      StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 
      encryptor.setPassword(mpCryptoPassword); 
      str = encryptor.encrypt(str); 
     } 
    return str; 
    } 
    public String decrypt(String str){ 
     if(str == null || str.equals("")){ 
      str = ""; 
     } 
     else{ 
      StandardPBEStringEncryptor decryptor = new StandardPBEStringEncryptor(); 
      decryptor.setPassword(mpCryptoPassword); 
      str = decryptor.decrypt(str); 
     } 
    return str; 
    } 

:

String encryptedToken = ""; 
//preparing token email + time 
Date now   = new Date();    
String prepareToken = "email="+email+"&tokenTime="+now.getTime(); 

//encrypt url value 
Encryptor enc  = new Encryptor(); 
encryptedToken  = enc.encrypt(prepareToken); 

을하고 내가 좋아하는 해독 오전 :

Encryptor enc   = new Encryptor(); 
String decryptedToken = enc.decrypt(encryptedToken); 

그 던지기 오류 :

org.jasypt.exceptions.EncryptionOperationNotPossibleException at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:1055) at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725) at com.cryptography.Encryptor.decrypt(Encryptor.java:57) at com.users.forgot.ResetPassword.doGet(ResetPassword.java:72) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at filters.charsetFilter.filter.CharsetFilter.doFilter(CharsetFilter.java:61) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:744)

업데이트
나는 그 언젠가 작동하지만 플러스 + 암호화 된 문자열 로그인되어 발견 공간으로는 점점 +

답변

0

문제로 암호화 된 문자열에서 기호 +가있는 경우 작동하지 않는 발견 . 해독 할 때 + URL에서 공백으로 표시됩니다.

encryptedToken = encryptedToken.replaceAll(" ","+"); 

이 문제를 해결