嗨,我有一個加密字符串來獲取用戶的pdf的問題。它顯示了一個錯誤,以下:加密的字符串長度
javax.crypto.IllegalBlockSizeException:帶襯墊的密
代碼解密時輸入長度必須是多個8是有:
public void getPDF(WebRequest request, ResourceResponse response, Model model,
@RequestParam("cif") String cif,
@RequestParam("cuenta") String cuenta,
@RequestParam("objectId") String encryptedObjectId) throws Exception{
log.info("Inicio metodo getPDF");
OutputStream os = response.getPortletOutputStream();
try {
CipherHelper cipher = new CipherHelper(CipherHelper.TRIPLE_DES_ALGORITHM, InterfazConstantes.ENCRYPTION_KEY, InterfazConstantes.ENCRYPTION_SHIFT);
String objectId = cipher.decrypt(encryptedObjectId, true);
public String getEncryptedObjectID() {
try {
CipherHelper cipher = new CipherHelper(CipherHelper.TRIPLE_DES_ALGORITHM, InterfazConstantes.ENCRYPTION_KEY, InterfazConstantes.ENCRYPTION_SHIFT);
encryptedObjectID = cipher.encrypt(objectID, true);
} catch (Exception e) {
}
return encryptedObjectID;
}
**我建立了encryptedObject ID有40個長度,但它沒有解決問題jet。
錯誤的軌跡是:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..) ~[sunjce_provider.jar:1.6]
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..) ~[sunjce_provider.jar:1.6]
有人能幫助我嗎?
感謝
不知道'CipherHelper'幹什麼,這將不可能在這裏幫助。請將您的代碼作爲一個[最小示例](http://stackoverflow.com/help/mcve)來演示您的問題。 –
這顯示總是這個錯誤,雖然我的字符串encryptedObjectId有8,16,32或64長度。這有些困惑,我認爲這個問題可能與這個參數的加密/解密有關。 –
我已投票結束。沒有更完整的代碼示例,我們無法提供幫助。 –