c# - Encrypt a custom section in app/web.config file -


i need encrypt/decrypt custom sections in app.config web.config file. read aspnet_regiis can used web.config, need programatically.

after opening mappedexeconfiguration, specify section follows:

configurationsection connstrings = config.appsettings; 

to encrypt/decrypt appsettings section.

how specify name of custom section? when type name of custom section after configurationsection object, intelli-sense not recognize it. (it recognizes few known sections)

p.s. in function, need take custom section name string parameter.

example:

e.g.

<configuration>    <mycustomtag>         <... data />     </mycustomtag>   </configuration> 

where mycustomtag section need encrypt/decrypt.

i achieved using code found @ http://www.a2zmenu.com/blogs/csharp/how-to-encrypt-configuration-file.aspx

i'd paste code in, pretty identical code on web page, except changing application names.

edit: custom section, i'm not sure did not need use it, explore config object gives in following line.

configuration config = configurationmanager.openexeconfiguration(getapppath() + "myappname.exe"); 

here entire updatekey() method, realise adapted bit web page. maybe helps.

public static void updatekey(string key, string newvalue)  {     configuration config = configurationmanager.openexeconfiguration(getapppath() + "myappname.exe");     config.appsettings.settings[key].value = newvalue;     config.save(); }  

then after have saved key(s), call

encryptappsettings("appsettings"); 

and perhaps can adapt param value suit there too.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -