I am currently serializing objects from my C# code to XML files. Somehow I need to also encrypte the XML file. What is the best method available that would allow me to do both the serialization and encryption?

Hi,

Do you need an industrial strength encryption (like AES, 3DES) or just need to scramble the content to make it human unreadable. For the former you have to use System.Security.Cryptography (there is 3DES implemented); for the latter you can just XOR each byte of the XML file with a key (of arbitrary length of bytes) repeatedly (omit the spaces and CRLF's on the XML to prevent recognizable shape) or you can replace each character of XML with x alphabetically next char where x is your position on the file (char #) mod number of possible chars or an arbitrary number. (i.e SOTH -> S+0 O+1 T+2 H+3 -> SPVK)

Loren Soth