use std::fs::File;
use std::io::{Read, Write};
pub fn encode_file(input_path: &str, output_path: &str, key: &str) -> std::io::Result<()> {
let mut file = File::open(input_path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let encoded = crate::encode::encode(&contents, key);
let mut out_file = File::create(output_path)?;
out_file.write_all(encoded.as_bytes())?;
Ok(())
}
pub fn decode_file(input_path: &str, output_path: &str, key: &str) -> std::io::Result<()> {
let mut file = File::open(input_path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
if let Some(decoded) = crate::decode::decode(&contents, key) {
let mut out_file = File::create(output_path)?;
out_file.write_all(decoded.as_bytes())?;
}
Ok(())
}