Programmatically encrypting a config-file in .NET

Seb Nilsson picture Seb Nilsson · Aug 22, 2008 · Viewed 15.4k times · Source

Could somebody please do a rundown of how to programmatically encrypt a config-file in .NET, preferably in C#.

What I would like to do is do some kind of check on an application's startup to see if a section is unprotected, and if it is, then encrypt it. This for both settings and connection-strings.

Also if anyone could list the types of encryption-providers and what is the difference between them.

I don't know if the code for doing this in a normal WinForms-application is transparent to doing this in ASP.NET.

Answer

Seb Nilsson picture Seb Nilsson · Aug 22, 2008

To summarize the answers and what I've found so far, here are some good links to answer this question:

Please feel free to complement with other links, maybe some to WinForms- or WPF-applications.