tommym121
asked on
C# - encrypt class structure into file.
Currently, I write an instance of class Setups into a file using XML serialization. And I will read the instance back when my application startup. I use result of the XML serialization as the configuration file of my application.
Now I would like to encrypt the result of the xml serialization and able to read it back into a class instance.
Currently.
Save configuration
class instance -->XML Serialization --> write XML file
Read configuraiont
Read XML File --> XML Serialization --> class instance
Now I am hoping to incorporate encrypt/decrypt
Save configuration
class instance -->XML Serialization --> encrypt --> write XML file
Read configuraiont
Read XML File --> decrypt --> XML Serialization --> class instance
Is this the right way to be expected or what is the right steps? And any good tutorial and examples for this type of operation?
Below is the class I try to do.
[XmlRootAttribute("Setups" , IsNullable = false)]
public class Setups
{
public int TradeType;
//[XmlArrayItem]
[XmlElement("Setup")]
public Setup[] Setup;
}
public class Setup
{
[XmlAttribute("entry")] public int _entry;
[XmlAttribute("type")] public string _typeString;
[XmlIgnore] public string _type;
[XmlElement("Name")] public string _name;
[XmlElement("Entry")] public string _entryName;
}
Now I would like to encrypt the result of the xml serialization and able to read it back into a class instance.
Currently.
Save configuration
class instance -->XML Serialization --> write XML file
Read configuraiont
Read XML File --> XML Serialization --> class instance
Now I am hoping to incorporate encrypt/decrypt
Save configuration
class instance -->XML Serialization --> encrypt --> write XML file
Read configuraiont
Read XML File --> decrypt --> XML Serialization --> class instance
Is this the right way to be expected or what is the right steps? And any good tutorial and examples for this type of operation?
Below is the class I try to do.
[XmlRootAttribute("Setups"
public class Setups
{
public int TradeType;
//[XmlArrayItem]
[XmlElement("Setup")]
public Setup[] Setup;
}
public class Setup
{
[XmlAttribute("entry")] public int _entry;
[XmlAttribute("type")] public string _typeString;
[XmlIgnore] public string _type;
[XmlElement("Name")] public string _name;
[XmlElement("Entry")] public string _entryName;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER
XmlSerializer serializer = new XmlSerializer(typeof(T));
TextWriter writer = new StreamWriter(filename);
serializer.Serialize(write
It seems that if there is a some type of encryptStreamWriter, it will be perfect.