C# .NET - Encrypt XML with Rijndael algorith ?

Asked By avula on 24-Sep-13 09:11 AM
Hi ,

I have generated one XML file from "student data" result set.  I have decided to follow the following algorithm.

Can you please suggest me, if i encrypt the XML data , which format of data do i need to send to user.

Where do i pass Decrypt key. please suggest me.


         string original = "Here is some data to encrypt!";

          // Create a new instance of the Rijndael
          // class.  This generates a new key and initialization  
          // vector (IV).
          using (Rijndael myRijndael = Rijndael.Create())
          {
            // Encrypt the string to an array of bytes.
            byte[] encrypted = EncryptStringToBytes(original, myRijndael.Key, myRijndael.IV);

            // Decrypt the bytes to a string.
            string roundtrip = DecryptStringFromBytes(encrypted, myRijndael.Key, myRijndael.IV);

            //Display the original data and the decrypted data.
            Console.WriteLine("Original:   {0}", original);
            Console.WriteLine("Round Trip: {0}", roundtrip);
            Console.ReadKey();
          }