public Stream DecryptFile(string inputFile)//, string outputFile)
{
{
string password = @"mykey"; // Your Key Here
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
FileStream fsCrypt = new FileStream(inputFile, FileMode.Open);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsCrypt,
RMCrypto.CreateDecryptor(key, key),
CryptoStreamMode.Read);
StreamReader sr = new StreamReader(cs);
Stream s = sr.BaseStream;
//sr.Close();
//fsCrypt.Close();
return s;
}
}
In this code there is a problem that stream is not closing properly. If I close it before returning the value then it throws an error.