public void CreateTripleDESFromString()
 {
     using (SymmetricCryptographyProvider provider = new SymmetricCryptographyProvider("System.Security.Cryptography.TripleDESCryptoServiceProvider", Util.GetRandomBytes(24)))
     {
         byte[] encrypted       = provider.Encrypt("ThisIsATest");
         byte[] decrypted       = provider.Decrypt(encrypted);
         string decryptedString = Encoding.ASCII.GetString(decrypted);
         Assert.AreEqual("ThisIsATest", decryptedString);
     }
 }
 public void CreateTripleDES()
 {
     using (SymmetricCryptographyProvider provider = SymmetricCryptographyProvider.TripleDES(Util.GetRandomBytes(24)))
     {
         byte[] encrypted       = provider.Encrypt(Encoding.ASCII.GetBytes("ThisIsATest"));
         byte[] decrypted       = provider.Decrypt(encrypted);
         string decryptedString = Encoding.ASCII.GetString(decrypted);
         Assert.AreEqual("ThisIsATest", decryptedString);
     }
 }
 public void CreateRijndaelFromString()
 {
     using (SymmetricCryptographyProvider provider = new SymmetricCryptographyProvider("System.Security.Cryptography.RijndaelManaged", Util.GetRandomBytes(32)))
     {
         byte[] encrypted       = provider.Encrypt("ThisIsATest");
         byte[] decrypted       = provider.Decrypt(encrypted);
         string decryptedString = Encoding.ASCII.GetString(decrypted);
         Assert.AreEqual("ThisIsATest", decryptedString);
     }
 }
        public void CreateDESFromUTF8EncodedBytes()
        {
            using (SymmetricCryptographyProvider provider = SymmetricCryptographyProvider.CreateDES(Util.GetRandomBytes(8)))
            {
                Encoding encoder = Encoding.UTF8;

                byte[] encrypted       = provider.Encrypt(encoder.GetBytes("ThisIsATest"));
                byte[] decrypted       = provider.Decrypt(encrypted);
                string decryptedString = encoder.GetString(decrypted);
                Assert.AreEqual("ThisIsATest", decryptedString);
            }
        }