using system;
using system. collections. generic;
using system. componentmodel;
using system. data;
using system. drawing;
using system. text;
using system. windows. forms;
using system. security. cryptography;
using system. io;
namespace jiami
{< br> Public partial class form1: form
{< br> // represents the abstract base class inherited by all symmetric algorithms .
Public repeated ricalgorithm symm = NULL;
Public form1 ()
{
Symm = new rijndaelmanaged ();
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
{
Try
{
String file = @ "F: \ 3.txt"; // original file
String tempfile = @ "F: \ 4.txt"; // path of the encrypted file
Filestream FSIN = file. Open (file, filemode. Open, fileaccess. Read );
Filestream fsout = file. Open (tempfile, filemode. Open, fileaccess. Write );
// defines symmetric algorithm object instances and interfaces
icryptotransform transform = symm. createencryptor ();
cryptostream cstream = new cryptostream (fsout, transform, cryptostreammode. write);
binaryreader BR = new binaryreader (FSIN);
// read the source file to cryptostream
cstream. write (BR. readbytes (INT) FSIN. length), 0, (INT) FSIN. length);
cstream. flushfinalblock ();
cstream. close ();
fsout. Close ();
FSIN. Close ();
This. textbox2.text = tempfile;
}< br> catch (exception ex)
{< br> throw ex;
}< br> private void button3_click (Object sender, eventargs e)
{< br> string tempfile = This. textbox2.text;
Filestream FSIN = file. Open (tempfile, filemode. Open, fileaccess. Read );
// Define symmetric algorithm object instances and interfaces
Icryptotransform transform = symm. createdecryptor ();
Cryptostream cstream = new cryptostream (FSIN, transform, cryptostreammode. Read );
Streamreader sr = new streamreader (cstream );
This. textbox3.text = Sr. readtoend ();
FSIN. Close ();
}
}< BR >}