Need an example of using xor-utils

Hello,
I am going to use xor-utils to xor encode/encryption of a file.
Unfortunately, I have a bit problem to perform this action.
Here is my sample code :

use std::io::Read;
use xor_utils::Xor;

//let mut buf = BytesMut::with_capacity(1024);
let mut file = File::open("file")?;
let encrypted  = file.xor("héllo");

Error :

n | let xa  = str_file.xor("héllo");
  |                    ^^^ method not found in `std::fs::File`

Because xor-utils has a kind of weird API, you'll need to call it like this:

let encrypted  = (&mut file).xor(&"héllo".as_bytes().to_vec());
2 Likes

This is another reason why we should avoid the type &Vec<T>

7 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.