using System; using System.Text; using System.IO; using System.Security.Cryptography; class Class1 {static void Main () {Console.WriteLine ( "Encrypt String ..."); txtKey = "tkGGRmBErvc ="; / / Set encryption key btnkeygen (); console.writeline ("Encrypt Key: {0}", txtKey); txtus = "kl7zgtm1dvq ="; // Setup encryption IV btnivgen (); console.writeline ("Encrypt IV: {0 } ", txtIV); Console.WriteLine (); string txtEncrypted = encryptString (" test "); Console.WriteLine (" Encrypt String: {0} ", txtEncrypted); string txtOriginal = DecryptString (txtEncrypted); Console.WriteLine ( "Decrypt String: {0}", txtOriginal);} private static SymmetricAlgorithm mCSP; private static string txtKey; private static string txtIV; private static void btnKeyGen () {mCSP = SetEnc (); byte [] byt2 = Convert.FromBase64String ( txtKey); mCSP.Key = byt2;} private static void btnIVGen () {byte [] byt2 = Convert.FromBase64String (txtIV); mCSP.IV = byt2;} private static string encryptString (string Value) {ICryptoTransform ct; MemoryStream ms ; CryptostReam Cs; Byte [] Byt; CT = mcsp.createEncryptor (mcsp.key, mcsp.iv); Byt = Encoding.utf8.GetBytes (Value); ms = new memoryStream (); cs = new cryptostream (MS, CT, CryptoStreamMode.Write); cs.Write (byt, 0, byt.Length); cs.FlushFinalBlock (); cs.Close (); return Convert.ToBase64String (ms.ToArray ());} private static string DecryptString (string Value ) {ICryptoTransform ct; MemoryStream ms; CryptoStream cs; byte [] byt; ct = mCSP.CreateDecryptor (mCSP.Key, mCSP.IV); byt = Convert.FromBase64String (Value); ms = new MemoryStream (); cs =