Wie kann man eine XML-Datei verschlüsseln / entschlüsseln?
Ich versuche eine XML-Datei zu ver- / entschlüsseln. Ich habe dieses Beispiel zum Verschlüsseln gefunden, weiß aber nicht, wie ich es entschlüsseln soll. Irgendeine Idee? Vielen Dank!
// 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");
Aber ich weiß nicht, wie ich das entschlüsseln würde? Irgendwelche Ideen? Vielen Dank!