以编程方式加密.​​NET中的配置文件

以编程方式加密.​​NET中的配置文件

问题描述:

可能有人请做一个如何编程加密配置文件在.NET中,最好是在C#中的一部分。

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.

我不知道在正常的WinForms应用程序中执行此操作的代码是否对在ASP.NET中执行此操作是透明的。

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

为了总结答案和我发现到目前为止,这里有一些很好的链接来回答这个问题:

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

  • Encrypting Configuration Information in ASP.NET 2.0 Applications - 4GuysFromRolla.com
  • How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI - MSDN

请随意补充其他链接,也许一些WinForms - 或WPF应用程序。

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