I have a need to export a fair amount of data out of an MSSQL query to an encrypted flat.
I need the “data at rest” to be encrypted without first saving it to an unencrypted file on the disk. If I had the option of first saving it unencrypted to the disk, I could just run PGP on the CSV file to encrypt it after the fact.
This means I need to encrypt it in memory after fetching it from the DB, probably by using a stream.
So that I don’t run out of memory, if fetching a lot of rows, it would be better to write to the disk (in encrypted format) in chunks. I.e., read a little, write a little (encrypted).
Is this possible? Any pseudo-code help possible?