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

<p>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.</p>

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

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

[{'answer_id': 21969, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 2, 'selected': False, 'text': '<p>There is a good article from 4 guys about <a href="https://web.archive.org/web/20211029043331/https://aspnet.4guysfromrolla.com/articles/021506-1.aspx" rel="nofollow noreferrer">Encrypting Configuration Information in ASP.NET 2.0 Applications</a></p>\n\n<p>Hope this helps</p>\n'}, {'answer_id': 21985, 'author': 'ArjanZuidhof', 'author_id': 2005, 'author_profile': 'https://Stackoverflow.com/users/2005', 'pm_score': 1, 'selected': False, 'text': '<p>@TK: a hashing algo can only be \'guessed\', not reverse engineered. One can only reconstruct the input to a hash value by completely guessing the input (apart from collisions, that is) This can be done by a rainbow crack for example (see <a href="http://www.antsight.com/zsl/rainbowcrack/" rel="nofollow noreferrer">an implementation of a rainbow cracker here</a>)</p>\n\n<p>I would say that a 3rd party encryption tool is not safer than the .NET framework encryption algorithms, these libraries just help you doing your job faster</p>\n'}, {'answer_id': 21989, 'author': 'DAC', 'author_id': 1111, 'author_profile': 'https://Stackoverflow.com/users/1111', 'pm_score': 0, 'selected': False, 'text': '<p>I haven\'t used it myself, but the Microsoft Enterprise library has good encryption support that will possibly suit your needs:</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/cc309503.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc309503.aspx</a></p>\n'}, {'answer_id': 21991, 'author': 'Seb Nilsson', 'author_id': 2429, 'author_profile': 'https://Stackoverflow.com/users/2429', 'pm_score': 5, 'selected': True, 'text': '<p>To summarize the answers and what I\'ve found so far, here are some good links to answer this question:</p>\n\n<ul>\n<li><a href="https://web.archive.org/web/20211029043331/https://aspnet.4guysfromrolla.com/articles/021506-1.aspx" rel="nofollow noreferrer">Encrypting Configuration Information in ASP.NET 2.0 Applications - 4GuysFromRolla.com</a></li>\n<li><a href="http://msdn.microsoft.com/en-us/library/ms998280.aspx" rel="nofollow noreferrer">How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI - MSDN</a></li>\n</ul>\n\n<p>Please feel free to complement with other links, maybe some to WinForms- or WPF-applications.</p>\n'}, {'answer_id': 7614607, 'author': 'Aviator007', 'author_id': 973644, 'author_profile': 'https://Stackoverflow.com/users/973644', 'pm_score': 2, 'selected': False, 'text': '<p>The solution at below site working fine for me.</p>\n\n<p><a href="http://www.a2zmenu.com/Blogs/CSharp/How-to-encrypt-configuration-file.aspx" rel="nofollow">http://www.a2zmenu.com/Blogs/CSharp/How-to-encrypt-configuration-file.aspx</a></p>\n'}]
['https://Stackoverflow.com/questions/21965', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2429/']