public void TEST_DECRYPT()
        {
            ISimpleStreamEncryption crypto = new DESStreamEncryption();
            String key = String.Empty;
            String iv = String.Empty;
            String decryptedText = String.Empty;

            using (FileStream fs = new FileStream(_keyFileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    key = sr.ReadToEnd();
                }
            }

            Assert.AreNotEqual(String.Empty, key);

            using (FileStream fs = new FileStream(_IVFileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    iv = sr.ReadToEnd();
                }
            }

            Assert.AreNotEqual(String.Empty, iv);

            using(FileStream fs = new FileStream(encrypt_name, FileMode.Open, FileAccess.Read) ){
                using (Stream decryptStream = crypto.DecryptStream(fs, key, iv))
                {
                    MemoryStream ms = new MemoryStream();
                    decryptStream.CopyTo(ms);

                    decryptedText = Encoding.ASCII.GetString(ms.ToArray());

                    Assert.AreEqual(_testTextFileContents, decryptedText);
                }
            }
        }
        public void TEST_ENCRYPT()
        {
            using (FileStream fs = new FileStream(file_name, FileMode.Create, FileAccess.ReadWrite))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write(_testTextFileContents);

                    Assert.IsTrue(File.Exists(file_name));
                }
            }

            ISimpleStreamEncryption crypto = new DESStreamEncryption();
            String key = crypto.GetKey();
            String iv = crypto.GetIV();

            using (FileStream fs = new FileStream(_keyFileName, FileMode.Create, FileAccess.ReadWrite))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write(key);
                    Assert.IsTrue(File.Exists(_keyFileName));
                }
            }

            using (FileStream fs = new FileStream(_IVFileName, FileMode.Create, FileAccess.ReadWrite))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write(iv);
                    Assert.IsTrue(File.Exists(_IVFileName));
                }
            }

            using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(_testTextFileContents)))
            {
                using (Stream encryptedStream = crypto.EncryptStream(ms, key, iv))
                {
                    encryptedStream.Seek(0, SeekOrigin.Begin);

                    MemoryStream eMS = new MemoryStream();
                    encryptedStream.CopyTo(eMS);

                    // On the fly decryption test!
                    String decryptedText = String.Empty;

                    using( Stream decryptedStream = crypto.DecryptStream(eMS, key, iv) ){
                        MemoryStream dMS = new MemoryStream();

                        decryptedStream.CopyTo(dMS);

                        decryptedText = Encoding.ASCII.GetString(dMS.ToArray());

                        Assert.AreEqual(_testTextFileContents, decryptedText);
                    }

                    encryptedStream.Seek(0, SeekOrigin.Begin);
                    using(FileStream fs = new FileStream(encrypt_name, FileMode.Create, FileAccess.Write ) ){
                        encryptedStream.CopyTo(fs);
                    }
                }
            }
        }