79360663

Date: 2025-01-16 07:20:49
Score: 5
Natty: 4.5
Report link

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 ?

Reasons:
  • Blacklisted phrase (0.5): how can i
  • Blacklisted phrase (1): what could be
  • RegEx Blacklisted phrase (1.5): how can i fix it ?
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: sarthak verma