Using System;
Using System. Security. Cryptography;
Using System. Text;
Using System. IO;
Using System. Windows. Forms;
Namespace Curllion
{
Public class Crypt
{
Private byte [] key;
Private byte [] iv;
Private System. Text. ASCIIEncoding asciiEncoding;
Private System. Text. UnicodeEncoding textConverter;
Private RC2CryptoServiceProvider rc2CSP;
Public Crypt ()
{
InitializeComponent ();
}
Private void InitializeComponent ()
{
Key = new byte [] {25,141,157,142, 23,111,234,159,187,154,215, 204 };
Iv = new byte [] {135,186,133,136,184,149,153,144 };
AsciiEncoding = new System. Text. ASCIIEncoding ();
TextConverter = new System. Text. UnicodeEncoding ();
Rc2CSP = new RC2CryptoServiceProvider ();
}
/// <Summary>
/// Create a new file with a size of 10261B to write encrypted data to a fixed size file.
/// </Summary>
/// <Param name = "filePath"> address of the file, including the file name </param>
Public void InitBinFile (string filePath)
{
Byte [] tmp = new byte [1, 10261];
Try // create a file stream and write all its content to 0
{
System. IO. FileStream writeFileStream = new FileStream (filePath,
System. IO. FileMode. Create,
System. IO. FileAccess. Write,
System. IO. FileShare. None, 512, false );
For (int I = 0; I <10261; I ++)
Tmp [I] = 0;
WriteFileStream. Write (tmp );
WriteFileStream. Flush ();
WriteFileStream. Close ();
}