Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a wpf application, when installing the application, i want to encrypt my app config file
how can i do that
Please help me

Thanks in advance
Kunjammu
Posted

1 solution

1.You can encrypt only the values of the settings used in you app config.

2.In order to do that you could use an symmetric encryption algorithm and create a simple application that encrypt the given values into an XML file (similar with app.config), then use these file as app.config, and finally decrypt the values from app.config in Window_Loaded event.

3.You can find examples about encryption in the next article: C# AES 256 bits Encryption Library with Salt[^]
 
Share this answer
 
v2
Comments
Kunjammu 15-Oct-14 1:40am    
I encrypted connection string by

ConfigurationSection section = config.GetSection("connectionStrings");

//Ensures that the section is not already protected
if (!section.SectionInformation.IsProtected)
{
//Uses the Windows Data Protection API (DPAPI) to encrypt the
//configuration section using a machine-specific secret key
section.SectionInformation.ProtectSection(
"DataProtectionConfigurationProvider");
config.Save();
}

but i can't encrypt system.web and sytem.serviceModel

How can i do this?
Raul Iloc 15-Oct-14 1:59am    
1.Like I told you in my solution above, you can encrypt any values of your app.config, then use that value, but before to use the encrypted values you have to decrypt them and manage the usage of them.
2.Regarding the WCF settings, if you really want to encrypt them, you could do it like I described in my solution, but then you must use these settings grammatically in your code. See details about this here: http://msdn.microsoft.com/en-us/library/hh205277(v=vs.110).aspx

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