Skip to main content

Crate rexor

Crate rexor 

Source
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:

Functions§

decode
Decodes a previously XOR-encoded file using the provided password. Returns the output path of the decoded file.
encode
Encodes a file using XOR with the provided password and input path. Returns the output path of the encoded file.