我收到错误“Cipher functions:EVP_DecryptFinal_ex:WRONG_FINAL_BLOCK_LENGTH”,我不知道为什么。有人可以告诉我如何解决这个问题吗?
以下是我的称呼方式
String encrypted = "E5ADDEB05D9D7B3925B7DE16B560D87C";
String sKey = "3985661DD71D591665BD39476636486B";
这是程序
public static String decrypt2(final String sEncryptedMessageBase64,
final String sSymKeyHex,
final String sIvHex)
{
final byte[] byteEncryptedMessage = Base64.decode(sEncryptedMessageBase64, Base64.DEFAULT);
try
{
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
final SecretKeySpec symKey = new SecretKeySpec(byteSymKeyData, "AES");
final IvParameterSpec iv = new IvParameterSpec(byteIvData);
cipher.init(Cipher.DECRYPT_MODE, symKey, iv);
final byte[] encodedMessage = cipher.doFinal(byteEncryptedMessage);
final String message = new String(encodedMessage, Charset.forName("UTF-8"));
return message;
}
catch (GeneralSecurityException e) {
Log.e("%%%%%", e.getMessage());
throw new IllegalStateException(
"Unexpected exception during decryption", e);
}
}
这是我得到的错误
error:1e06b07b:Cipher functions:EVP_DecryptFinal_ex:WRONG_FINAL_BLOCK_LENGTH
感谢您提供的任何帮助