這裏是我的加密器類方法:爲什麼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)
更新
我注意到它的某個工作,但時有加密的字符串作爲其獲得+作爲空間