I know .Net 2.0 has xml encryption, but I wanted to know the best way to encrypt xml in 1.1. What I want to do, is have an XML file created, that is unreadable without the decryption tools. I've encrypted .txt files before, and could encrypte the xml file after it's been written, but I'd rather encrypt it while, or before it's written. Any techniques?
write the XML to a string, then encrypt the string, then write the string to a file?
That could work... thanks.
Or you can encrypt only parts of the xml file.
We use encrypted XML for license files. Create the XML DOM, get the inner XML string, encrypt and write to file.
If you want to have valid XML that contains excrypted strings then you have to encrypt each DOM node's contents individually. You might also want to look at XML digital signatures to check that file file has not been tampered with.
ZippyV wrote:Or you can encrypt only parts of the xml file.
Exactly what I would do. Use an XmlTextWriter, XmlDocument, etc, to create the heirarchy, and encrypt specific values within. Encrypting the entire heirarchy could take time, depending on how large it is. Besides, it's unnecessary unless the actual element names should be a secret too.
(Sorry for being off-topic here, but does anyone know of an XOP implementation for .NET?)
Hope that helped.