File Encrypt/Decrypt under load?

Posted by chopps on Stack Overflow See other posts from Stack Overflow or by chopps
Published on 2010-03-16T21:53:22Z Indexed on 2010/03/16 22:31 UTC
Read the original article Hit count: 261

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about fileencryption

Related posts about ASP.NET