pub fn decrypt(data: &[u8], key: &[u8], iv: &[u8]) -> io::Result<Vec> {
let cipher = Aes256Cbc::new_from_slices(key, iv).expect("Invalid key or IV");
let decrypted_data = match cipher.decrypt_vec(data) {
Ok(data) => data,
Err(e) => {
eprintln!("Decryption failed: {}", e); // Log the error message
return Err(io::Error::new(io::ErrorKind::InvalidData, format!("Decryption failed: {}", e)));
}
};
println!("Decrypted data size: {}", decrypted_data.len());
Ok(decrypted_data)
}
i am getting the iv correct the data length is also same as encrypted, but still i am receiving "Decryption failed: BlockModeError" what could be the reason for this or how can i fix it ?