use fs_crypto::*; use std::path::Path; use std::ffi::OsStr; use std::io::{ self, Read, Write }; use std::fs::{ File, remove_file }; #[test] fn encrypt_file_test() -> Result<(), io::Error> { let test_data = Vec::from("123456"); let test_filename = Path::new("./test"); let output_filename = OsStr::new("./enc"); let encrypted_filename = Path::new("./enc"); let result_filename = OsStr::new("./res"); File::create(test_filename)?.write_all(&test_data)?; let password = Vec::from("1234567"); encrypt_file(test_filename, output_filename, &password).unwrap(); decrypt_file(encrypted_filename, result_filename, &password).unwrap(); let mut result_data = Vec::new(); File::open(result_filename)?.read_to_end(&mut result_data)?; assert_eq!(test_data, result_data); remove_file(test_filename)?; remove_file(output_filename)?; remove_file(result_filename)?; Ok(()) }