Reputation: 31
I am trying to implement an efficient solution for file encryption with Botan, however, all code examples I've seen use different input and output files for encryption. For example, this code taken directly from documentation:
DataSource_Stream in("in.txt");
Pipe pipe(get_cipher("AES-128/CTR-BE", key, iv),
new DataSink_Stream("out.txt"));
pipe.process_msg(in);
I know I can just rename the output file to the input one and delete the input, but that just seems like a waste of storage, since we effectively create an encrypted copy of the file, doubling used space. My question is how to implement a same-file DataSource & DataSink Pipe. I've tried to change the "out.txt" string to "in.txt", but it just seems to append the ciphertext to in.txt, not write over it.
Upvotes: 3
Views: 84