[][src]Function enc_file::decrypt_aes

pub fn decrypt_aes(enc: Vec<u8>, key: &str) -> Result<Vec<u8>, Box<dyn Error>>

Decrypts ciphertext (Vec) with a key (&str) using AES256 GCM SIV. Returns result (cleartext as Vec).

Examples

use enc_file::{encrypt_aes, decrypt_aes};
let text = b"This a test";
let key: &str = "an example very very secret key.";
let text_vec = text.to_vec();
let ciphertext = encrypt_aes(text_vec, key).unwrap();
assert_ne!(&ciphertext, &text);
let plaintext = decrypt_aes(ciphertext, key).unwrap();
assert_eq!(format!("{:?}", text), format!("{:?}", plaintext));