Xml Serialization with Encryption RRS feed

  • Question

  • Hi

    At present i have two classes: a Data class and a DataCollection class which inherits a List (Of Data). I use serialization to write the contents of the DataCollection class to an Xml file and so far works perfectly. What i would like is to be able to use encryption to encrypt certain values for specific properties - some are ok viewed as plain text where as some are more sensitive.

    Rather than encrypting the whole Xml file, is it possible to just encrypt the data stored within the Xml tags?

    I've considered using Reflection to iterate through the properties within the class and writing a custom Serialization routine to read and write to Xml. I've also thought about creating a custom attribute which i could set against each property to determine if encryption should be applied - something which i could also determine using Reflection. Would this be the way to do it or are easier methods available?

    Thanks in advance


    Sunday, January 25, 2009 12:03 PM


  • Kev,

    For some reason, your post only just now appeared!

    If this is still a problem for you, I suggest you consider implementing IXmlSerializable on the class you need to serialize. You will be able to dictate exactly how instances of the class serialize and deserialize.

    John Saunders | Use File->New Project to create Web Service Projects
    Friday, February 13, 2009 9:37 PM