File Encrypt/Decrypt under load?
- by chopps
I found an interesting article about encrypting and decrypting files but since it uses a file.dat to store the key this will run into problems when theres alot of users on the site dealing with alot of files.
http://www.codeproject.com/KB/security/VernamEncryption.aspx?display=Print
Should a new file be created every time a file needs decrypting or would there be a better way to do this?
UPDATE:
Here is what im using to avoid the locking problems.
using (Mutex FileLock = new Mutex(true, System.Guid.NewGuid().ToString()))
{
try
{
FileLock.WaitOne();
using (FileStream fs = new FileStream(keyFile, FileMode.Open))
{
keyBytes = new byte[fs.Length];
fs.Read(keyBytes, 0, keyBytes.Length);
}
}
catch (Exception ex)
{
EventLog.LogEvent(ex);
}
finally
{
FileLock.ReleaseMutex();
}
}
I tested it on 1000 TIFFs doing both encryption and decryption without any errors.