How do i encrypt a file in C#? i would like to use a db (like sqlite) and use it normally except have the file encrypted and have my user enter his password before having access to the database.
+2
A:
SQL Server Compact Edition (it's an inprocess database server like SQLite) allows you to encrypt the file without writing any additional code.
To change the password, use the Engine.Compact method.
overslacked
2009-03-09 03:17:32
+7
A:
There are multiple ways to do this:
- Use DPApi (Data Protection API), which is supplied in the ProtectedData (System.Security.Cryptography class), and use an entrophy based on a password
- Use SQL Compact Edition, which has this built in
- Generate a key based on a password and encrypt/decrypt the file with that
- Use Encrypted File System, so the OS will take care of encryption on the disk. (Consumer editions of Windows don't have this though.)
And there are probably more ways to do this.
Hope this helps.
Jeroen Landheer
2009-03-09 03:20:36
If you use EFS remember to back up the keys!
RobS
2009-04-26 09:47:12
As with any security application, encrypted data without a key is like a locked door without a key. You may be able to get in, but it is going to take a lot of time :)
Jeroen Landheer
2009-04-28 06:47:49
A:
SQLiteConnection.SetPassword
I think you also have to set the Password= parameter in the connection string.
blue_fenix
2009-04-26 09:43:35