I am trying to encrypt data that a serializable (xml) class contains. Here is a simple example:
[XmlRootAttribute("FooClass")]
public class FooClass
{
private string _personalData;
public PersonalData
{
set { _personalData = value;}
get { return _personalData; }
}
}
Assume there are ready to be used tho methods: Encrypt & Decrypt. Is there a way to use them somehow during the serialization in order to encrypt PersonalData in the serialized output?
Yes. Mark PersonalData as nonserialized, then add a new property to return and accept the serialized data (note that the XmlAttribute is optional):