I am trying to create a decrypted File stream reader (DFSR) class by subclassing StreamReader so I can pass the filename with encrpyted info to its (DFSR) constructor and return with the streamReader that I can call upon ReadLine method of StreamReader.
I know how to do it as below, but I do not know how to refractor it into a class with StreamReader as parent class.
using (Rijndael rijAlg = Rijndael.Create())
{
rijAlg.Key = DX_KEY_32;
rijAlg.IV = DX_IV_16;
// Create a decrytor to perform the stream transform.
using (FileStream fs = File.Open("test.crypt", FileMode.Open))
{
using (CryptoStream cs = new CryptoStream(fs, rijAlg.CreateDecryptor(), CryptoStreamMode.Read))
{
using (StreamReader sr = new StreamReader(cs))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
}
}