解密它時,我得到了下面的錯誤,我能夠但是對數據進行加密:加密和解密使用的Blowfish錯誤 - 與解密時輸入長度必須是多個的8填充密碼
錯誤
HTTP Status 500 - Request processing failed; nested exception is javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
這是我的加密和解密代碼
//secret key 8
private static String strkey ="Blowfish";
修訂
//encrypt using blowfish algorithm
public static byte[] encrypt(String Data)throws Exception{
SecretKeySpec key = new SecretKeySpec(strkey.getBytes("UTF8"), "Blowfish");
Cipher cipher = Cipher.getInstance("Blowfish");
cipher.init(Cipher.ENCRYPT_MODE, key);
return (cipher.doFinal(Data.getBytes("UTF8")));
}
//decrypt using blow fish algorithm
public static String decrypt(byte[] encryptedData)throws Exception{
SecretKeySpec key = new SecretKeySpec(strkey.getBytes("UTF8"), "Blowfish");
Cipher cipher = Cipher.getInstance("Blowfish");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decrypted = cipher.doFinal(encryptedData);
return new String(decrypted);
}
我在類中得到以下錯誤構造函數Base64(布爾)未定義爲私有靜態Base64 base64 =新Base64(true); – devdar 2013-04-29 23:35:42
你能給我一些關於這個問題的建議嗎http://stackoverflow.com/questions/16290808/spring-mvc-url-mapping-in-controller-for-dynamic-urls?noredirect=1#comment23324237_16290808 – devdar 2013-04-30 10:54:55
你還可以看看在這個問題對我來說http://stackoverflow.com/questions/16305926/springmvc-looping-through-list-data-passed-from-the-view – devdar 2013-04-30 22:04:28