Click-Once - How to encrypt connection strings [duplicate]

拜拜、爱过 提交于 2019-12-01 17:01:11

问题


I have a WPF application with connections strings stored in the App.config. What is the best way of encrypting these connection strings in a click-once deployment?

Thanks


回答1:


If this is a connectionString that will be configured and used on a single computer (not shared across multiple computers) by an instance of your application, you can use the .NET managed wrapper of the DPAPI (Data Protection API) - the ProtectedData class (System.Security.Cryptography).

A neat trick you could also use (should you decide to use this class) is to create extension methods for Encoding and Decoding a string, so the operations become as simple as:

string encodedString = myConnectionString.EncodeString();

string decodedString = encodedString.DecodeString();

Hope this helps!



来源:https://stackoverflow.com/questions/890396/click-once-how-to-encrypt-connection-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!