title: How to encrypt/decrypt an XML file?
body: <p>I am trying to encrypt/decrypt an XML file. I found this sample for encrypting but I do not know how to decrypt? Any idea? Thanks!</p>
  
  <pre><code>        // Load this XML file
          System.Xml.XmlDocument myDoc = new System.Xml.XmlDocument();
          myDoc.Load(@"c:\persons.xml");
          // Get a specified element to be encrypted
          System.Xml.XmlElement element = myDoc.GetElementsByTagName("Persons")[0] as System.Xml.XmlElement;
  
          // Create a new TripleDES key. 
          System.Security.Cryptography.TripleDESCryptoServiceProvider tDESkey = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
  
          // Form a Encrypted XML with the Key
          System.Security.Cryptography.Xml.EncryptedXml encr = new System.Security.Cryptography.Xml.EncryptedXml();
          encr.AddKeyNameMapping("Deskey", tDESkey);
  
          // Encrypt the element data
          System.Security.Cryptography.Xml.EncryptedData ed = encr.Encrypt(element, "Deskey");
  
          // Replace the existing data with the encrypted data
          System.Security.Cryptography.Xml.EncryptedXml.ReplaceElement(element, ed, false);
  
          // saves the xml file with encrypted data
          myDoc.Save(@"c:\encryptedpersons.xml");
  </code></pre>
  
  <p>But I do not know how I would decrypt that? Any ideas? Thanks!</p>