[−][src]Function enc_file::decrypt_chacha
pub fn decrypt_chacha(
enc: Vec<u8>,
key: &str
) -> Result<Vec<u8>, Box<dyn Error>>
Decrypts ciphertext (Vec
Examples
use enc_file::{encrypt_chacha, decrypt_chacha}; let text = b"This a test"; let key: &str = "an example very very secret key."; // encrypt_chacha takes plaintext as Vec<u8>. Text needs to be transformed into vector let text_vec = text.to_vec(); let ciphertext = encrypt_chacha(text_vec, key).unwrap(); assert_ne!(&ciphertext, &text); let plaintext = decrypt_chacha(ciphertext, key).unwrap(); assert_eq!(format!("{:?}", text), format!("{:?}", plaintext));