Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Encryption file file-system IO , +
I have a file which should be opened in a third-party program. That file is encrypted until it is needed. When the user runs my C# program, it will decrypt the file, open it with the third-party software, then when the software is done, it will re-encrypt the file. The third-party cannot do the encryption and decryption itself.
 
The problem with this setup is that during the time the third-party program is open, the file is exposed to the world. It can be copied and pasted elsewhere, ruining the purpose of the encryption.
 
I'd like to fix this flaw. I'm not sure how to prevent the file from being copied. I tried using a virtual file system called Dokan, which will supposedly allow me to change how a file is read or written to. The main problem with it is that I can't figure out how to control the read/write of this file to prevent copying. I think Dokan also requires NTFS filesystems, which I shouldn't assume the end-user has.
 
Is there another way to control read/write on a file in C#?
Posted 2-Dec-12 17:38pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Not really. The only option I really see is decrypting the file in-memory and passing that to the third-party application.
 
The flaw really lies in the fact that the third party application doesn't do the encryption/decryption itself AND doesn't provide a way to pass in the decrypted information.
  Permalink  
Comments
Franklin Barnett at 3-Dec-12 1:19am
   
Perhaps it might be possible to use some sort of alternative of "Sandboxie"? Essentially that program allows you to run programs in a sandbox so that they don't save files to the hard drive, which is handy for downloading sketchy-looking programs. I'll look into this...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Found out my issue. Granted the whole scheme is a bit unorthodox, but modifying the target application itself isn't practical.
 
I ended up revisiting the Dokan solution. Dokan creates a sort of virtual hard drive out of an empty folder or creates a new drive. This time I successfully modified it in the way I want, and now I can control how various applications interact with the file.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 Sergey Alexandrovich Kryukov 170
4 PIEBALDconsult 160
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100