Expand description
This library provides simple file encryption and decryption using XOR logic.
It allows you to encode or decode any file with a defined password,
producing .rxor encrypted files.
§Example: Encoding a file
use rexor::encode;
fn main() -> std::io::Result<()> {
let input = "example.txt";
let password = "password123";
// Encode the file into "example.txt.rxor"
let output = encode(input, password, None)?;
println!("Encoded file saved at: {}", output);
Ok(())
}§Example: Decoding a file
use rexor::decode;
fn main() -> std::io::Result<()> {
let input = "example.txt.rxor";
let password = "password123";
// Decode the file back to its original form
let output = decode(input, password, None)?;
println!("Decoded file saved at: {}", output);
Ok(())
}§Example: Custom output path
use rexor::{encode, decode};
fn main() -> std::io::Result<()> {
let input = "example.txt";
let password = "password123";
// Encode to a custom location
let encoded = encode(input, password, Some("encrypted/output.rxor"))?;
// Decode back into another file
let decoded = decode(&encoded, password, Some("decrypted/example.txt"))?;
println!("Encoded: {}", encoded);
println!("Decoded: {}", decoded);
Ok(())
}§Errors
The functions return std::io::Result<String>.
Typical errors include:
- Invalid input paths or missing files
- Empty password (
std::io::ErrorKind::InvalidInput) - I/O issues while reading or writing files