Encrypting a "stream" with AES
<p>I continuously produce a string that I need to write to a local file (encrypted).</p>

<p>As I'm already having an AES library in my application, I would prefer to use AES - if possible.</p>

<p>Approach 1: AES has a block size of 16 bytes, so I need to buffer 16 bytes of data in memory that I might lose if the computer crashes.</p>

<p>Approach 2: Writing all the data to the file first and periodically encrypt the whole file with AES-CBC. This way, the user could access the unencrypted file for a short period of time.</p>

<p>Is there any other way?</p>