Read / write to the same file - WeOnlyDo Discussion board

Read / write to the same file (General questions)

by dandraka, Monday, February 21, 2005, 14:00 (7214 days ago)

Hello again,

While encrypting (or decrypting), is it possible to read from and write to the same file ?

Our situation is like this: There is a disk file which is an encrypted database. It can grow large enough, so the stuff that need to be done (decrypt it, update some records and then encrypt it again) cannot be done in-memory.

So far we are using an encryption component (which has other problems, so we want to get rid of it) that is able to encrypt/decrypt using a single file. For example, at the middle of the encryption process, the file is half decrypted, half encrypted.

If the process would stop right in the middle for some reason (which BTW we have no way of knowing with the current component; this is its main problem, it doesn't throw an exception or return an error code, nothing) then the database would be entirely corrupt. In our case, this is a nice thing to have. Why ? Because if the process fails, the user cannot use the (corrupted) database. This very db is what we're trying to protect from the eyes of the user.

We have, of course, thought about writing the decrypted file to the disk and then (after we update the records and encrypt it again) deleting it. But this would leave the decrypted file, even for a few seconds, somewhere where a user can copy it.

Is wodCrypt capable of something similar ? Or, alternatively, can you think of a possible solution for our case ?

Thanks in advance,

Dimitris Andrakakis


Complete thread: