Click here to Skip to main content
15,888,264 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi All,

I am trying to encrypt appsettings of app.config file by using following code:
String path = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\App.Config";
Configuration config = ConfigurationManager.OpenExeConfiguration(path);
ConfigurationSection appSettings = config.GetSection("appSettings");
appSettings.SectionInformation.ForceSave = true;
appSettings.SectionInformation.ProtectSection("ProtectedConfigurationSection");
config.Save();


Neither I m getting any error Nor appsetting are getting encrypted. Now, What Should I do to ENCRYPT appsettings?

Really need help!

Regards!
Aman
Posted

See this article:

http://msdn.microsoft.com/en-us/library/ms254494.aspx[^]

Scroll down to the section titled:

"Encrypting Configuration File Sections Using Protected Configuration"

It was introduced for ASP.NET, but you can use it from Winforms and WPF applications too.
 
Share this answer
 
v2
Take a look at this article
Encrypt App.settings of App.config[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900