Search code examples
c#encryptionzipon-the-fly

C# Adding Strings to encrypted zip file "on the fly"


I have this problem:

I have an application which harvests some information which is necessary to be stored on disk but I don't want to other see/access it so easily (due the safety I don't want to store it on disk in plain form). Information is plain text Stringbuffer and from time to time - when buffer reaches approx. 16kByte I want to store that buffer directly into encrypted zip(or any other archive) file. Options are: 1. Add new ~16kB file to encrypted zip 2. Append buffer to existing file in encrypted zip

Is that possible? If so, how? Any help or link how to do it?


Solution

  • Is it really a requirement to use ZIP? It is definitely possible to do, but complicates matters.

    To start, I would have a look at CryptoStream, there are several examples out there on how to make use of it, e.g. here. This would allow you to keep writing to the stream, and let it worry about the implementation details.