pub fn decrypt_with_aes(
ciphertext: &[u8],
key: &[u8; 32],
iv: &[u8; 16],
) -> Result<Vec<u8>, Box<dyn Error>>Expand description
Decrypt a message using AES-256-CBC with a custom IV
§Arguments
ciphertext- The encrypted ciphertext to decryptkey- A 32-byte encryption key (must match encryption key)iv- A 16-byte initialization vector (must match encryption IV)
§Returns
Returns a Result containing the decrypted plaintext as Vec
§Example
use askrypt::{encrypt_with_aes, decrypt_with_aes};
let message = b"Hello, World!";
let key = [0u8; 32];
let iv = [0u8; 16];
let ciphertext = encrypt_with_aes(message, &key, &iv).unwrap();
let plaintext = decrypt_with_aes(&ciphertext, &key, &iv).unwrap();
assert_eq!(message, &plaintext[..]);