XORCryptor Lib

Algorithm for encrypting and decrypting based on XOR bitwise operation

About algorithm

crates.io docs.rs

Usage

For 64 bit CPU:

```rust use xor_cryptor::XORCryptor;

fn main() { let sampletext = String::from("Hello World !"); let key = String::from("secretkey"); let buffer = sampletext.asbytes().to_vec();

let res = XORCryptor::new(&key);
if res.is_err() {
    return;
}
let xrc = res.unwrap();

let encrypted_buffer = xrc.encrypt_vec(buffer);
let encrypted_string = String::from_utf8_lossy(&encrypted_buffer);
println!("Encrypted: {}\n", encrypted_string);

// This encrypted string contains formatted non-utf8 characters
// Do not use this string as vector to decrypt
let decrypted_buffer = xrc.decrypt_vec(encrypted_string.as_bytes().to_vec());
println!(
    "Decrypted from string : {:?}",
    String::from_utf8_lossy(&decrypted_buffer)
);

let decrypted_buffer = xrc.decrypt_vec(encrypted_buffer);
println!(
    "Decrypted from vec    : {:?}",
    String::from_utf8_lossy(&decrypted_buffer)
);

} ```

For rest:

```rust use xor_cryptor::XORCryptor;

fn main() { let sampletext = String::from("Hello World !"); let key = String::from("secretkey");

let mut buffer = sampletext.asbytes().tovec(); let res = XORCryptor::new(&key); if res.iserr() { return; } let xrc = res.unwrap(); xrc.encrypt_vec(&mut buffer);

let encryptedstring = String::fromutf8lossy(&buffer); println!("Encrypted: {}\n", encryptedstring);

// This encrypted string contains formatted non-utf8 characters // Do not use this string as vector to decrypt let mut dbuff = encryptedstring.asbytes().tovec(); xrc.decryptvec(&mut dbuff); println!("Decrypted from string : {:?}", String::fromutf8lossy(&d_buff));

xrc.decryptvec(&mut buffer); println!("Decrypted from vec : {:?}", String::fromutf8_lossy(&buffer)); } ```

Output

``shell $ cargo run Compiling xor_cryptor v1.0.0 (XYZ) Finished dev [unoptimized + debuginfo] target(s) in 0.21s Runningtarget/debug/xor_cryptor.exe`

Encrypted: W"♣'"�jMLQ�-

Decrypted from string: "Hell:4u��D6S\u{c}\u{1e}��K" Decrypted from vec : "Hello World !" ```