ok so I got half-way there, I was able to encrypt an element in my XML file, now I want to learn how to decrypt it.
Here is my encryption code:
Any ideas how I reverse it to read the element and decrypt it and read the result to a string?Code:System.Xml.XmlDocument myDoc = new System.Xml.XmlDocument(); myDoc.Load("settings.xml"); System.Xml.XmlElement element = myDoc.GetElementsByTagName("TechPass")[0] as System.Xml.XmlElement; System.Security.Cryptography.TripleDESCryptoServiceProvider tDESkey = new System.Security.Cryptography.TripleDESCryptoServiceProvider(); System.Security.Cryptography.Xml.EncryptedXml encr = new System.Security.Cryptography.Xml.EncryptedXml(); encr.AddKeyNameMapping("Deskey", tDESkey); System.Security.Cryptography.Xml.EncryptedData ed = encr.Encrypt(element,"Deskey"); System.Security.Cryptography.Xml.EncryptedXml.ReplaceElement(element, ed, false); myDoc.Save("settings.xml");




Reply With Quote