Encrypt only one subsection in a config file RRS feed

  • Question

  • Hi,


    Is there a way to protect only one element (sub-section) within a section using the SectionInformation.ProtectSection method?


    If not, is there any other way to do that without having to implement the whole encryption myself?

    I'm trying to encrypt just one element within <appSettings> (let's say <add key="myKey" value="myValue">) and it looks like it's "all the section or nothing" if I use this method.

    Your help is much appreciated. Thanks!

    Tuesday, February 5, 2008 4:36 PM


  • Hi Martin,


    Using appSettings element is the easiest choice to store application settings but not always the best one.


    I suggest you to create custom configuration section within configuration file, like <mySettings> and create custom class to read this config section. Then you will be easily able to encrypt this config section.

    Wednesday, February 6, 2008 8:08 AM